<semantics>
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
.
注意: 传统的 MathML 规范允许渲染器根据可用的注释决定默认渲染方式。以下确定可见子节点的规则已在某些浏览器中实现。有关 Presentation 和 Content MathML 之间的区别,请参阅 MathML 4。
- 如果没有任何其他规则适用:默认情况下,仅渲染第一个子节点,该子节点应该是 Presentation MathML。
- 如果第一个子节点是 Presentation MathML 元素(
<annotation>
或<annotation-xml>
除外),则渲染第一个子节点。 - 如果没有找到 Presentation MathML,则渲染
<semantics>
的第一个<annotation>
或<annotation-xml>
子节点元素,这些元素没有src
属性。对于<annotation-xml>
元素,encoding
属性必须等于以下值之一"application/mathml-presentation+xml"
"MathML-Presentation"
"SVG1.1"
"text/html"
"image/svg+xml"
"application/xml
".
请注意,这里没有提到 "application/mathml+xml"
,因为它不区分 Content 或 Presentation MathML。
属性
<semantics>
、<annotation>
和 <annotation-xml>
元素接受 全局 MathML 属性。此外,可以在 <annotation>
和 <annotation-xml>
元素上设置以下属性
示例
html
<math display="block">
<semantics>
<!-- The first child is the MathML expression rendered by default. -->
<mrow>
<msup>
<mi>x</mi>
<mn>2</mn>
</msup>
<mo>+</mo>
<mi>y</mi>
</mrow>
<!-- Annotate with "Content MathML", a dedicated XML dialect to
express the meaning of mathematical formulas. -->
<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 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>
</semantics>
</math>
规范
规范 |
---|
MathML Core # semantics-and-presentation |
浏览器兼容性
BCD 表仅在浏览器中加载