<semantics>

  • Revision slug: MathML/Element/semantics
  • Revision title: semantics
  • Revision id: 74415
  • Created:
  • Creator: jswisher
  • Is current revision? No
  • Comment 1 words added, 1 words removed

Revision Content

Summary

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. By default only the first child is rendered, which is supposed to be presentation markup. In Gecko only the first child is displayed at all and other annotations are hidden ({{ bug("154931") }}).
  • The <annotation> element is the container element containing semantic information in a non-XML format.
  • The <annotation-xml> element can be used as a container element including semantic information in an XML format, e.g. Content MathML or OpenMath.

Attributes

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

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

Example

<math>
  <semantics>

    <!-- Presentation MathML (first child, rendered by Gecko) -->
    <mrow>
      <msup>
        <mi>x</mi>
        <mn>2</mn>
      </msup>
      <mo>+</mo>
      <mi>y</mi>
    </mrow>

    <!-- Content MathML -->
    <annotation-xml encoding="MathML-Content">
      <apply>
        <plus/>
        <apply>
          <power/>
          <ci>x</ci>
          <cn type="integer">2</cn>
        </apply>
        <ci>y</ci>
      </apply>
    </annotation-xml>

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

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

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{ CompatNo() }} {{ CompatGeckoDesktop("1.0") }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }}
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support {{ CompatNo() }} {{ CompatGeckoMobile("1.9.2") }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }}

Specification

  • {{ spec("http://www.w3.org/TR/MathML/chapter5.html","MathML 3.0 Mixing Markup Languages for Mathematical Expressions ", "REC") }}

Revision Source

<h2 id="Summary">Summary</h2>
<p>In MathML there are two ways to mark up mathematics: <em>Presentation</em> MathML is used to control the layout of equations, whereas <em>Content</em> MathML is designed to encode the semantic mathematical meaning and to make expressions understandable to computer algebra systems. The MathML elements <code>&lt;semantics&gt;</code>, <code>&lt;annotation&gt;</code> and <code>&lt;annotation-xml&gt;</code> are used to combine presentation and content markup and to provide both, layout information and semantic meaning of mathematical expressions.</p>
<ul> <li>The <code>&lt;semantics&gt;</code> element acts as a container element associating annotations. By default only the first child is rendered, which is supposed to be presentation markup. In Gecko only the first child is displayed at all and other annotations are hidden ({{ bug("154931") }}).</li> <li>The <code>&lt;annotation&gt;</code> element is the container element containing semantic information in a non-XML format.</li> <li>The <code>&lt;annotation-xml&gt;</code> element can be used as a container element including semantic information in an XML format, e.g. Content MathML or OpenMath.</li>
</ul>
<h2 id="Attributes">Attributes</h2>
<p>The following attributes can be set on <code>&lt;annotation&gt;</code> and <code>&lt;annotation-xml&gt;</code>:</p>
<dl> <dt id="attr-definitionurl">definitionURL</dt> <dd>The location of the annotation key symbol.</dd> <dt id="attr-encoding">encoding</dt> <dd>The encoding of the semantic information in the annotation (e.g. "MathML-Content", "MathML-Presentation", "application/openmath+xml", "image/png")</dd> <dt id="attr-cd">cd</dt> <dd>The content dictionary that contains the annotation key symbol.</dd> <dt id="attr-name">name</dt> <dd>The name of the annotation key symbol.</dd> <dt id="attr-src">src</dt> <dd>The location of an external source for semantic information.</dd>
</dl>
<h2 id="Example">Example</h2>
<pre class="brush: html">&lt;math&gt;
  &lt;semantics&gt;

    &lt;!-- Presentation MathML (first child, rendered by Gecko) --&gt;
    &lt;mrow&gt;
      &lt;msup&gt;
        &lt;mi&gt;x&lt;/mi&gt;
        &lt;mn&gt;2&lt;/mn&gt;
      &lt;/msup&gt;
      &lt;mo&gt;+&lt;/mo&gt;
      &lt;mi&gt;y&lt;/mi&gt;
    &lt;/mrow&gt;

    &lt;!-- Content MathML --&gt;
    &lt;annotation-xml encoding="MathML-Content"&gt;
      &lt;apply&gt;
        &lt;plus/&gt;
        &lt;apply&gt;
          &lt;power/&gt;
          &lt;ci&gt;x&lt;/ci&gt;
          &lt;cn type="integer"&gt;2&lt;/cn&gt;
        &lt;/apply&gt;
        &lt;ci&gt;y&lt;/ci&gt;
      &lt;/apply&gt;
    &lt;/annotation-xml&gt;

    &lt;!-- annotate an image --&gt;
    &lt;annotation encoding="image/png" src="some/path/formula.png"/&gt;

    &lt;!-- annotate TeX --&gt;
    &lt;annotation encoding="application/x-tex"&gt;
      x^{2} + y 
    &lt;/annotation&gt; 
   
  &lt;/semantics&gt;
&lt;/math&gt;</pre>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
<table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Chrome</th> <th>Firefox (Gecko)</th> <th>Internet Explorer</th> <th>Opera</th> <th>Safari</th> </tr> <tr> <td>Basic support</td> <td>{{ CompatNo() }}</td> <td>{{ CompatGeckoDesktop("1.0") }}</td> <td>{{ CompatNo() }}</td> <td>{{ CompatNo() }}</td> <td>{{ CompatNo() }}</td> </tr> </tbody>
</table>
</div>
<div id="compat-mobile">
<table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Android</th> <th>Firefox Mobile (Gecko)</th> <th>IE Phone</th> <th>Opera Mobile</th> <th>Safari Mobile</th> </tr> <tr> <td>Basic support</td> <td>{{ CompatNo() }}</td> <td>{{ CompatGeckoMobile("1.9.2") }}</td> <td>{{ CompatNo() }}</td> <td>{{ CompatNo() }}</td> <td>{{ CompatNo() }}</td> </tr> </tbody>
</table>
</div>
<h2 id="Specification">Specification</h2>
<ul> <li>{{ spec("http://www.w3.org/TR/MathML/chapter5.html","MathML 3.0 Mixing Markup Languages for Mathematical Expressions ", "REC") }}</li>
</ul>
Revert to this revision