MyInternships.in

HTML5 MathML

HTML5 MathML <mn> Tag

The <mn> element represents a numeric literal - an integer, decimal or any run of digits treated as a single number. Numbers are rendered upright, distinct from italic identifiers.


Definition and Usage

Wrap each number in its own <mn> so the browser spaces and styles it correctly. Decimal points, digit groups and even numbers in other bases can appear inside <mn>. Keep operators like the minus sign in <mo>, not <mn>.

Syntax

Numeric literals
Example
<mn>42</mn>
<mn>3.14159</mn>

Attributes

AttributeDescription
mathvariantStyle such as normal, bold or double-struck.
mathsizeFont size of the number.
mathcolorText colour of the number.
mathbackgroundBackground colour behind the number.

Example

Numbers in an approximation of pi
Example
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>MathML mn</title>
</head>
<body>
  <math display="block">
    <mrow>
      <mi>&#960;</mi>
      <mo>&#8776;</mo>
      <mn>3.14159</mn>
    </mrow>
  </math>
</body>
</html>
💡

Use a separate <mo> for a leading minus sign - <mo>-</mo><mn>5</mn> - so it is treated as an operator, not part of the number.

Key Takeaways

  • <mn> holds a numeric literal and renders it upright.
  • Each number gets its own <mn>; operators stay in <mo>.
  • mathvariant and mathsize adjust the appearance.

Related HTML Topics

Keep learning with these closely related tutorials.

Ready to use your HTML skills?

Find web development internships and fresher jobs across India.

Browse Web Dev Internships