1. Home
  2. Docs
  3. HTML5
  4. Bài 7: Tổng quan MathML

Bài 7: Tổng quan MathML

Hầu hết trình duyệt web có thể hiển thị các thẻ MathML. Nế trình duyệt của bạn không hỗ trợ MathML, thì khi đó chúng tôi đề nghị bạn sử dụng phiên bản Firefox mới nhất.

MathML hợp lệ

Code mẫu:

<!doctype html>
<html>
   <head>
      <meta charset="UTF-8">
      <title>Pythagorean</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> 

Kết quả: a2 + b2 = c2

Sử dụng các ký tự MathML

Code mẫu:

<!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>&InvisibleTimes;</mo>
                  <mi>x</mi>
               </mrow>
               <mo>+</mo>
               <mn>4</mn>
            </mrow>
            <mo>=</mo>
            <mn>0</mn>
         </mrow>
      </math>
   </body>
</html> 

Kết quả: x 2 + 4 ⁢ x + 4 = 0

Biểu diễn Ma trận

Code mẫu:

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

Kết quả: A = x y z w