<semantics>

Baseline 2023
Newly available

Since January 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

Das <semantics> MathML-Element verknüpft Anmerkungen mit einem MathML-Ausdruck, zum Beispiel dessen Textquelle als Lightweight Markup Language oder mathematische Bedeutung, die in einem speziellen XML-Dialekt ausgedrückt wird. Typischerweise hat es die folgende Struktur:

Standardmäßig wird nur das erste Kind des <semantics>-Elements gerendert, während die anderen das display auf none gesetzt haben.

css
semantics > :not(:first-child) {
  display: none;
}

Hinweis: Ältere MathML-Spezifikationen erlaubten es den Renderern, die Standarddarstellung gemäß den verfügbaren Anmerkungen festzulegen. Die folgenden Regeln zur Bestimmung des sichtbaren Kindes wurden in einigen Browsern implementiert. Siehe MathML 4 für die Unterscheidung zwischen Presentation und Content MathML.

  • Wenn keine anderen Regeln zutreffen: Standardmäßig wird nur das erste Kind gerendert, das Presentation MathML sein soll.
  • Wenn das erste Kind ein Presentation MathML-Element ist, das nicht <annotation> oder <annotation-xml> ist, rendern Sie das erste Kind.
  • Wenn kein Presentation MathML gefunden wird, rendern Sie das erste <annotation> oder <annotation-xml> Kind-Element von <semantics> ohne ein src-Attribut. Für <annotation-xml>-Elemente muss das encoding-Attribut gleich einem der folgenden Werte sein:
    • "application/mathml-presentation+xml"
    • "MathML-Presentation"
    • "SVG1.1"
    • "text/html"
    • "image/svg+xml"
    • "application/xml"

Beachten Sie, dass "application/mathml+xml" hier nicht erwähnt wird, da es nicht zwischen Content oder Presentation MathML unterscheidet.

Attribute

Die Attribute dieses Elements umfassen die globalen MathML-Attribute.

Beispiel

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="application/mathml-content+xml">
      <apply>
        <plus />
        <apply>
          <power />
          <ci>x</ci>
          <cn type="integer">2</cn>
        </apply>
        <ci>y</ci>
      </apply>
    </annotation-xml>

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

Technische Zusammenfassung

Spezifikationen

Specification
MathML Core
# semantics-and-presentation

Browser-Kompatibilität

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
semantics
Use the algorithm described on MDN to determine the visible child.
DeprecatedNon-standard

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Non-standard. Check cross-browser support before using.
Deprecated. Not for use in new websites.