阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

HTML5 MathML简介

62次阅读
没有评论

共计 2596 个字符,预计需要花费 7 分钟才能阅读完成。

导读 HTML5 可以在文档中使用 MathML 元素,对应的标签是 <math>…</math>。

HTML5 MathML 简介

MathML 是数学标记语言,是一种基于 XML(标准通用标记语言的子集)的标准,用来在互联网上书写数学符号和公式的置标语言。

注意:目前只有 Firefox 或 Safari 浏览器支持,大部分浏览器还不支持 MathML 标签,如果你的浏览器不支持该标签,可以使用最新版的 Firefox 或 Safari 浏览器查看。

MathML 实例

以下是一个简单的 MathML 实例:

实例

<!DOCTYPE html>
<html>
   <head>
      <meta charset="UTF-8">
      <title> 菜鸟教程 (runoob.com)</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>

使用第三方库来支持:

实例

<!DOCTYPE html>
<html>
   <head>
      <meta charset="UTF-8">
      <title> 菜鸟教程 (runoob.com)</title>
      <script type="text/javascript" src="https://static.runoob.com/assets/js/mathml/mspace.js"></script>
   </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>

运行结果图,如下所示:
HTML5 MathML 简介
以下实例添加了一些运算符:

实例

<!DOCTYPE html>
<html>
   <head>
      <meta charset="UTF-8">
      <title> 菜鸟教程 (runoob.com)</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>

使用第三方库来支持:

实例

<!DOCTYPE html>
<html>
   <head>
      <meta charset="UTF-8">
      <title> 菜鸟教程 (runoob.com)</title>
      <script type="text/javascript" src="https://static.runoob.com/assets/js/mathml/mspace.js"></script>
   </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>
                  <mi>x</mi>
               </mrow>                                      
               <mo>+</mo>
               <mn>4</mn>                                       
            </mrow>                               
            <mo>=</mo>
            <mn>0</mn>                                 
         </mrow>
      </math>               
   </body>
</html>

运行结果图,如下所示:
HTML5 MathML 简介
以下实例是一个 2×2 矩阵,可以在 Firefox 3.5 以上版本查看到效果:

实例

<!DOCTYPE html>
<html>
   <head>
      <meta charset="UTF-8">
      <title> 菜鸟教程 (runoob.com)</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>

使用第三方库来支持:

实例

<!DOCTYPE html>
<html>
   <head>
      <meta charset="UTF-8">
      <title> 菜鸟教程 (runoob.com)</title>
      <script type="text/javascript" src="https://static.runoob.com/assets/js/mathml/mspace.js"></script>
   </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>

运行结果图,如下所示:
HTML5 MathML 简介

阿里云 2 核 2G 服务器 3M 带宽 61 元 1 年,有高配

腾讯云新客低至 82 元 / 年,老客户 99 元 / 年

代金券:在阿里云专用满减优惠券

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2024-07-24发表,共计2596字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中