HTML5 MathML

HTML5 MathML <math> Tag

The <math> tag is the top-level container for every MathML expression. Placing it in an HTML5 document tells the browser to render the enclosed markup as mathematical notation.


Definition and usage

The <math> element is the root of any MathML fragment. All other MathML elements must be nested inside it. Its display attribute controls whether the equation renders inline with text (display="inline", the default) or as a centred block on its own line (display="block").

Syntax

<math display="block">
  <!-- MathML expression -->
</math>

Example

A simple equation as a block-level formula
<math display="block">
  <mrow>
    <mi>E</mi>
    <mo>=</mo>
    <mi>m</mi>
    <msup><mi>c</mi><mn>2</mn></msup>
  </mrow>
</math>

With display="block", the formula is rendered centred on its own line; using display="inline" (or omitting the attribute) keeps it flowing within surrounding text at a smaller size.

ℹ️

The <math> element is supported natively in all modern browsers. In older Chromium versions before 109 it needed a polyfill such as MathJax; today no library is required.

Ready to use your HTML skills?

Find web development internships and fresher jobs across India.

Browse Web Dev Internships