<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.

<semantics>MathML の要素で、 MathML 表現に注釈を付けます。例えば、軽量マークアップ言語としてのテキストソース、または特別な XML 方言で表現されている数学的意味などです。一般的に、その構造は以下の通りです。

  • 注釈を付けるべき MathML 式である最初の子。
  • 続く <annotation> または <annotation-xml> 要素。後者は OpenMath のような XML 形式のために予約されています。

既定では、<semantics>要素の最初の子要素だけがレンダリングされ、他の子要素は displaynone を設定した状態で保有されます。

メモ: 古い MathML 仕様では、レンダラーが利用できる注釈に従って既定のレンダリングを決定することができました。可視の子を決定する以下のルールは、いくつかのブラウザーで実装されています。表示する MathML とコンテンツ MathML の区別については、 MathML 4 を参照してください。

  • 適用すべき規則が他にない場合、既定では最初の子要素のみ描画され、これが表示 MathML と見なされます。
  • 最初の子要素が <annotation> または <annotation-xml> 以外の表示 MathML 要素の場合、当要素が描画されます。
  • 表示 MathML が見当らない場合、 src 属性のない <semantics> 要素の最初の <annotation> または <annotation-xml> 子要素を描画します。 <annotation-xml> 要素については、 encoding 属性が以下のいずれかの値と等しくなければいけません。
    • "application/mathml-presentation+xml"
    • "MathML-Presentation"
    • "SVG1.1"
    • "text/html"
    • "image/svg+xml"
    • "application/xml".

ここに "application/mathml+xml" を挙げていないことに留意してください、というのもこれでは内容 MathML か表示 MathML かを区別できないからです。

属性

<semantics><annotation><annotation-xml> の各要素はグローバル MathML 属性を受け入れます。さらに、<annotation><annotation-xml> 要素には、以下の属性を設定することができます。

encoding

この注釈における意味的情報の符号化方法(例: "MathML-Content", "MathML-Presentation", "application/openmath+xml", "image/png")。

src 非推奨;

意味的情報の外部ソースの場所。

html
<math display="block">
  <semantics>
    <!-- 最初の子は、既定でレンダリングされる MathML 式です。 -->
    <mrow>
      <msup>
        <mi>x</mi>
        <mn>2</mn>
      </msup>
      <mo>+</mo>
      <mi>y</mi>
    </mrow>

    <!-- 数式の意味を表現するための専用 XML 方言 "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>

    <!-- 数式の PNG 画像で注釈を付けます。 -->
    <annotation encoding="image/png" src="some/path/formula.png" />

    <!-- 数式を書くための軽量なマークアップ言語である LaTeX で
         注釈をつけることができます。 -->
    <annotation encoding="application/x-tex"> x^{2} + y </annotation>
  </semantics>
</math>

仕様書

Specification
MathML Core
# semantics-and-presentation

ブラウザー互換機

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.