HTML <math> Element

The HTML <math> element is the top-level container used to embed MathML mathematical expressions directly within an HTML document.

Syntax

<math>
  MathML content
</math>

The <math> element requires both an opening and closing tag. MathML elements are placed inside it to describe the structure and meaning of the mathematical expression.

Attributes

The <math> element supports the global HTML attributes and also supports attributes defined by MathML.

Example

This example uses MathML inside the <math> element to display the mathematical expression x² + y² = z².

Play in Editor

Usage Notes

The <math> element provides the entry point for MathML content in an HTML document. The mathematical expression itself is constructed with MathML elements placed inside the <math> container.

MathML describes the structure of mathematical notation rather than representing an equation as an image. This allows mathematical expressions to remain part of the document and gives browsers and assistive technologies more information about the content.

Common MathML elements include <mi> for identifiers such as variables, <mn> for numbers, <mo> for operators, <msup> for superscripts, and <mfrac> for fractions.

Accessibility

Using MathML provides structured mathematical content that can be interpreted by compatible browsers and assistive technologies. This is generally more accessible than presenting an equation only as an image because the mathematical structure remains available to software.

Keep the MathML structure accurate and meaningful so assistive technologies can interpret the expression correctly. If an image of a mathematical expression must be used instead, provide an appropriate text alternative.

Browser Support

Baseline: Widely available indicates a feature has been supported by core browsers for at least 30 months. At this stage, the feature is considered stable and safe for most websites to use without needing to worry about compatibility issues or fallbacks, as it is supported by the vast majority of users' devices and browser versions.

For detailed browser compatibility information, see Can I Use: MathML .

The <math> element contains MathML elements rather than ordinary HTML elements for constructing mathematical expressions. Common MathML elements include <mi>, <mn>, <mo>, <msup>, <msub>, <mfrac>, and <msqrt>.

Specifications

HTML Living Standard: MathML