MDN will be in maintenance mode on Wednesday September 20th, starting at 10 AM Pacific / 5 PM UTC, for about 1 hour.

我们的志愿者还没有将这篇文章翻译为 中文 (简体)加入我们帮助完成翻译!
您也可以阅读此文章的English (US)版。

In MathML there are two ways to mark up mathematics: Presentation MathML is used to control the layout of equations, whereas Content MathML is designed to encode the semantic mathematical meaning and to make expressions understandable to computer algebra systems. The MathML elements <semantics>, <annotation> and <annotation-xml> are used to combine presentation and content markup and to provide both, layout information and semantic meaning of mathematical expressions.

The <semantics> element acts as a container element associating annotations and must have child elements (it will raise an invalid markup error otherwise). The <annotation> element is the container element containing semantic information in a non-XML format, whereas the <annotation-xml> element contains content in an XML format, e.g. Content MathML or OpenMath.

The rules of determining the visible child in a <semantics> element are the following:

  • If no rule other rule applies: By default only the first child is rendered, which is supposed to be presentation markup.
  • 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>.
    Beware that <annotation-xml> elements are only recognized, if the encoding attribute is set to one of the following:
    • "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.


The following attributes can be set on <annotation> and <annotation-xml>:

The location of the annotation key symbol.
The encoding of the semantic information in the annotation (e.g. "MathML-Content", "MathML-Presentation", "application/openmath+xml", "image/png")
The content dictionary that contains the annotation key symbol.
The name of the annotation key symbol.
The location of an external source for semantic information.



    <!-- Presentation MathML -->

    <!-- Content MathML -->
    <annotation-xml encoding="MathML-Content">
          <cn type="integer">2</cn>

    <!-- annotate an image -->
    <annotation encoding="image/png" src="some/path/formula.png"/>

    <!-- annotate TeX -->
    <annotation encoding="application/x-tex">
      x^{2} + y 


Specification Status Comment
MathML 3.0
The definition of 'Mixing Markup Languages for Mathematical Expressions' in that specification.
Recommendation Current specification
MathML 2.0
The definition of 'Combining Presentation and Content Markup ' in that specification.
Recommendation Initial specification

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support No support 1.0 (1.7 or earlier) No support No support No support
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support No support No support 1.0 (1.9.2) No support No support No support

Gecko-specific notes

  • The algorithm of determining the visible child in <semantics> has been corrected in (Firefox 23 / Thunderbird 23 / SeaMonkey 2.20) to match the MathML specification. In prior versions the first child element has been rendered.
  • In Gecko <annotation> and <annotation-xml> elements are ignored if the src attribute is set.


 此页面的贡献者: fscholz, Sheppy, jswisher
 最后编辑者: fscholz,