當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


HTML5 MathML <semantics>標記用法及代碼示例

HTML5 MathML <semantics>標記是HTML 5中的內置元素。它用於標記數學,有兩種方法可以標記數學。

  • 介紹MathML用於控製任何數學方程式的布局。
  • 內容MathML旨在對語義數學含義進行編碼,並使表達式可為計算機代數係統所理解。

此標記充當應包含子元素的容器元素。與該標簽一起執行的還有兩個標簽,分別是<annotation>標簽和<annotation-xml>。此標記<annotation>元素是那些元素的容器,並包含非XML格式的語義信息,而<annotation-xml>元素包含XML格式的內容,例如Content MathML或OpenMath。

用法:


<semantics> child elements </semantics>

屬性:該標記接受下麵提到的屬性,並且必須在<annotation>和<annotation-xml>上使用這些屬性。

  • definitionURL:此屬性保存注釋符號的位置。
  • encoding:此屬性用於對注釋中的語義信息進行編碼。
  • cd:此屬性用於保存注釋符號。
  • name:此屬性保存注釋鍵符號的名稱。
  • src:此屬性保存用於語義信息的外部源的位置。

下麵的示例說明了HTML 5中的<semantics>標記:

<!DOCTYPE html> 
<html> 
  
<head> 
    <title>HTML 5 MathML <semantics> tag</title> 
</head> 
  
<body> 
    <center> 
        <h1 style="color:green">  
            GeeksforGeeks  
        </h1> 
  
        <h3>HTML5 MathML <semantics> tag</h3> 
  
        <math> 
            <semantics> 
  
                <!-- Presentation MathML -->
                <mrow> 
                    <msup> 
                        <mi>x</mi> 
                        <mn>2</mn> 
                    </msup> 
                    <mo>+</mo> 
                    <msup> 
                        <mi>y</mi> 
                        <mn>2</mn> 
                    </msup> 
                    <mo>=</mo> 
                    <msup> 
                        <mi>z</mi> 
                        <mn>2</mn> 
                    </msup> 
                </mrow> 
  
                <!-- Content MathML -->
                <annotation-xml encoding="MathML-Content"> 
                    <apply> 
                        <plus/> 
                        <apply> 
                            <power/> 
                            <ci>x</ci> 
                            <cn type="integer">2</cn> 
                        </apply> 
                        <apply> 
                            <power/> 
                            <ci>y</ci> 
                            <cn type="integer">2</cn> 
                        </apply> 
                        <equal/> 
                        <apply> 
                            <power/> 
                            <ci>z</ci> 
                            <cn type="integer">2</cn> 
                        </apply> 
                    </apply> 
                </annotation-xml> 
  
                <!-- annotate of an image -->
                <annotation encoding="image/png" src= 
"https://media.geeksforgeeks.org/wp-content/uploads/20191226151654/762.png" /> 
  
                <!-- annotate of Text -->
                <annotation encoding="application/x-tex"> 
                    x^{2} + y^{2} = z^{2} 
                </annotation> 
  
            </semantics> 
        </math> 
    </center> 
</body> 
</html>                    

輸出:

支持的瀏覽器:下麵列出了HTML 5 MathML <semantics>標記支持的瀏覽器:

  • Firefox


相關用法


注:本文由純淨天空篩選整理自skyridetim大神的英文原創作品 HTML5 | MathML <semantics> Tag。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。