MyInternships.in

HTML5 MathML

HTML5 MathML Tags

Presentation MathML provides a set of tags that build up mathematical layout - rows, fractions, roots, scripts and tables. The tables below list the elements you place inside the <math> root, and the example shows several working together.


Token Elements (leaf content)

TagDescription
<mi>An identifier such as a variable or function name (italic by default).
<mn>A numeric literal.
<mo>An operator, fence or separator such as +, =, ( or ).
<mtext>Ordinary text inside a formula.
<ms>A string literal, rendered inside quotes.
<mspace>Blank space of a given width or height.

Layout and Script Elements

TagDescription
<mrow>Groups sub-expressions horizontally as a single unit.
<mfrac>Builds a fraction from a numerator and denominator.
<msqrt>Draws a square root over its contents.
<mroot>Draws an nth root with an index.
<msup>Attaches a superscript (exponent).
<msub>Attaches a subscript.
<msubsup>Attaches both a subscript and a superscript.
<mover>Places an accent or object over an expression.
<munder>Places an object under an expression.
<mtable>Creates a table or matrix layout of rows and cells.

Example

This document combines a fraction, an exponent and a square root to render Pythagoras' theorem solved for the hypotenuse.

Several presentation tags working together
Example
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>MathML Tags</title>
</head>
<body>
  <math display="block">
    <mrow>
      <mi>c</mi>
      <mo>=</mo>
      <msqrt>
        <mrow>
          <msup><mi>a</mi><mn>2</mn></msup>
          <mo>+</mo>
          <msup><mi>b</mi><mn>2</mn></msup>
        </mrow>
      </msqrt>
    </mrow>
  </math>
</body>
</html>
💡

Wrap multi-part numerators, denominators and radicands in <mrow> so the browser treats them as one group and spaces them correctly.

Key Takeaways

  • Token elements (<mi>, <mn>, <mo>) hold the actual symbols.
  • Layout elements (<mfrac>, <msqrt>, <msup>) arrange those symbols in two dimensions.
  • <mrow> is the glue that groups pieces into single logical units.
  • All tags live inside a single <math> element.

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