htmlmathml

how to use MathML in HTML


I'm trying to displaying math formula on a web page. But when I write html code like following

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
    <title>Binomial Theorem</title>
</head>
<body>
<p>Binomial Theorem:</p>
<math xmlns="http://www.w3.org/1998/Math/MathML">
    <mrow>
        <msup>
            <mfenced>
                <mrow>
                    <mi>a</mi>
                    <mo>+</mo>
                    <mi>b</mi>
                </mrow>
            </mfenced>
            <mn>2</mn>
        </msup>
        <mo>=</mo>
        <msup>
            <mrow>
                <mi>a</mi>
            </mrow>
            <mn>2</mn>
        </msup>
        <mo>+</mo>
        <msup>
            <mrow>
                <mi>b</mi>
            </mrow>
            <mn>2</mn>
        </msup>
        <mo>+</mo>
        <mrow>
            <mn>2</mn>
            <mi>a</mi>
            <mi>b</mi>
        </mrow>
    </mrow>
</math>
</body>
</html>

And the result is just

Binomial Theorem:

a + b 2 = a 2 + b 2 + 2 a b

It is not like a formula

help me to use MathML in HTML Thanks,


Solution

  • MathML isn't supported by all popular user agents. Firefox 3.5 or later releases, for example, do support it:

    The MathML snippet rendered by Firefox 3.5