MathML? Good Idea :)

Fri 22 August 2014
x = b ± b 2 4 a c 2 a

See the above, this is all MathML Magic and when we take a look at the source, plain text:

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>x</mi>
    <mo>=</mo>
    <mfrac>
      <mrow>
        <mo>&#x2212;</mo>
        <mi>b</mi>
        <mo>&#xB1;</mo>
        <msqrt>
          <mrow>
            <msup>
              <mi>b</mi>
              <mn>2</mn>
            </msup>
            <mo>&#x2212;</mo>
            <mn>4</mn>
            <mi>a</mi>
            <mi>c</mi>
          </mrow>
        </msqrt>
      </mrow>
      <mrow>
        <mn>2</mn>
        <mi>a</mi>
      </mrow>
    </mfrac>
  </mrow>
</math>

Yeah, quite complex, let us take the amazing Pythagorean theorem:

a2 + b2 = c2

The code would look like this:

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"> 
  <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>

If you want more examples click here for the W3C ones.

Stay :yin_yang: and keep coding :)

Category: math Tagged: math web html markup mathml xml