在HTML5中使用MathML數(shù)學(xué)公式的簡(jiǎn)單講解

字號(hào):


    這篇文章主要介紹了在HTML5中使用MathML數(shù)學(xué)公式的簡(jiǎn)單講解,math標(biāo)簽的妙用往往可以收貨意想不到的效果,需要的朋友可以參考下
    HTML5 的 HTML 語(yǔ)法允許我們?cè)谖臋n內(nèi)使用 <math>...</math> 標(biāo)簽應(yīng)用 MathML 元素。
    下面是一個(gè)使用 MathML 的有效 HTML5 文檔:
    XML/HTML Code
    html   
    <!doctype html>  
      <html>  
      <head>  
      <meta charset="UTF-8">  
      <title>Pythagorean theorem</title>  
      </head>  
      <body>  
        <math xmlns="http://www.w3.org/1998/Math/MathML">  
          <mrow>  
            <msup><mi>a</mi><mn>2</mn></msup>  
            <mo>+</mo>  
            <msup><mi>b</mi><mn>2</mn></msup>  
            <mo>=</mo>  
            <msup><mi>c</mi><mn>2</mn></msup>  
          </mrow>  
        </math>  
      </body>  
    </html>    
    這會(huì)生成如下結(jié)果:
    復(fù)制代碼代碼如下:
    a2 + b2 = c2
    便于學(xué)習(xí)這一概念 - 請(qǐng)使用 FireFox 3.7 或更高版本進(jìn)行在線練習(xí)。
    使用 MathML 字符
    想象一下,下面是一個(gè)使用字符 &InvisibleTimes; 的標(biāo)記:
    XML/HTML Code
    html   
    <!doctype html>  
      <html>  
      <head>  
      <meta charset="UTF-8">  
      <title>MathML Examples</title>  
      </head>  
      <body>  
        <math xmlns="http://www.w3.org/1998/Math/MathML">  
           <mrow>  
              <mrow>  
                 <msup>  
                    <mi>x</mi>  
                    <mn>2</mn>  
                 </msup>  
                 <mo>+</mo>  
                 <mrow>  
                    <mn>4</mn>  
                    <mo>⁢</mo>  
                    <mi>x</mi>  
                 </mrow>  
                 <mo>+</mo>  
                 <mn>4</mn>  
              </mrow>  
                 <mo>=</mo>  
                 <mn>0</mn>  
            </mrow>  
       </math>  
    </body>  
    </html>   
    這會(huì)生成如下結(jié)果
    復(fù)制代碼代碼如下:
    x 2 + 4 x + 4 = 0
    便于學(xué)習(xí)這一概念 - 請(qǐng)使用 FireFox 3.7 或更高版本進(jìn)行在線練習(xí)。
    矩陣表達(dá)示例
    想象一下下面的例子,它會(huì)被用來(lái)表示一個(gè)簡(jiǎn)單的 2x2 矩陣:
    XML/HTML Code
    html   
    <!doctype html>  
      <html>  
      <head>  
      <meta charset="UTF-8">  
      <title>MathML Examples</title>  
      </head>  
      <body>  
        <math xmlns="http://www.w3.org/1998/Math/MathML">  
           <mrow>  
              <mi>A</mi>  
              <mo>=</mo>  
              <mfenced open="[" close="]">  
                 <mtable>  
                    <mtr>  
                       <mtd><mi>x</mi></mtd>  
                       <mtd><mi>y</mi></mtd>  
                    </mtr>  
                    <mtr>  
                       <mtd><mi>z</mi></mtd>  
                       <mtd><mi>w</mi></mtd>  
                    </mtr>  
                 </mtable>  
             </mfenced>  
          </mrow>  
       </math>  
    </body>  
    </html>   
    這會(huì)生成如下結(jié)果
    名單