The <semantics> MathML element associates annotations with a MathML expression, for example its text source as a lightweight markup language or mathematical meaning expressed in a special XML dialect. Typically, its structure is:

  • a first child which is a MathML expression to be annotated.
  • subsequent <annotation> or <annotation-xml> elements, the latter being reserved for XML formats such as OpenMath.

By default, only the first child of the <semantics> element is rendered while the others have their display set to none.

Note: Legacy MathML specifications allowed renderers to decide the default rendering according to available annotations. The following rules for determining the visible child have been implemented in some browsers. See MathML 4 for the distinction between Presentation and Content MathML.

  • If no other rules apply: By default only the first child is rendered, which is supposed to be Presentation MathML.
  • If the first child is a Presentation MathML element other than <annotation> or <annotation-xml>, render the first child.
  • If no Presentation MathML is found, render the first <annotation> or <annotation-xml> child element of <semantics> without a src attribute. For <annotation-xml> elements the encoding attribute must be equal to one of following values:
    • "application/mathml-presentation+xml"
    • "MathML-Presentation"
    • "SVG1.1"
    • "text/html"
    • "image/svg+xml"
    • "application/xml".

Note that "application/mathml+xml" is not mentioned here as it does not distinguish between Content or Presentation MathML.


<semantics>, <annotation> and <annotation-xml> elements accept the global MathML attributes. Additionally, the following attributes can be set on the <annotation> and <annotation-xml> elements:


The encoding of the semantic information in the annotation (e.g. "MathML-Content", "MathML-Presentation", "application/openmath+xml", "image/png")

src Deprecated

The location of an external source for semantic information.


<math display="block">
    <!-- The first child is the MathML expression rendered by default. -->

    <!-- Annotate with "Content MathML", a dedicated XML dialect to
         express the meaning of mathematical formulas. -->
    <annotation-xml encoding="MathML-Content">
        <plus />
          <power />
          <cn type="integer">2</cn>

    <!-- Annotate with a PNG image of the formula. -->
    <annotation encoding="image/png" src="some/path/formula.png" />

    <!-- Annotate with LaTeX, a lightweight markup language to write
         mathematical formulas. -->
    <annotation encoding="application/x-tex"> x^{2} + y </annotation>


MathML Core
# semantics-and-presentation

Browser compatibility

BCD tables only load in the browser