当前位置:首页 > HTML5教程 > HTML5入门

HTML5MathML

html5 mathml

html5 可以在文档中使用 mathml 元素,对应的标签是 <math>...</math> 。

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

注意:大部分浏览器都支持 mathml 标签,如果你的浏览器不支持该标签,可以使用最新版的 firefox 或 safari 浏览器查看。

mathml 实例

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

实例

运行结

实例

<!doctype html>
<html>
   <head>
      <meta charset="utf-8">
      <title>无忧网</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>无忧网</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>

 

以下实例是一个 2×2 矩阵,可以在 firefox 3.5 以上版本查看到效果:

<!doctype html>
<html>
   <head>
      <meta charset="utf-8">
      <title>无忧网</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>

【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!