5

My browser, Firefox 3.6, seems to display the Mathml equations in the W3C test suite just fine. But if I copy the code into my webpage, like from here, all Firefox produces is something like x y x y instead of how it correctly rendered the W3C page. What am I missing here>

EDIT: I just tried it in Chrome and Chrome failed the test itself by rendering it as x y x y. Needless to say, it rendered the math in my own webpage the same.

EDIT 2: I tried it on a new html document. Doesn't work:

<!DOCTYPE html>
<html lang="en">
  <head>
    <title></title>
  </head>
  <body>
<math display="inline" xmlns="http://www.w3.org/1998/Math/MathML" mode="display">
  <mfrac>
    <mi>x</mi>
    <mi>y</mi>
  </mfrac>
    </math>
    <math display="block" xmlns="http://www.w3.org/1998/Math/MathML" mode="inline">
  <mfrac>
    <mi>x</mi>
    <mi>y</mi>
      </mfrac>
    </math>
  </body>
</html>

I swear the W3C equations render just fine though...

Luke Singham
  • 1,536
  • 2
  • 20
  • 38
wrongusername
  • 18,564
  • 40
  • 130
  • 214

4 Answers4

9

Including

<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=MML_HTMLorMML"></script>

and then using

    <math xmlns="http://www.w3.org/1998/Math/MathML">
        <mroot>
            <mrow>
                <mi>x</mi>
            </mrow>
            <mn>4</mn>
        </mroot>
    </math>

works in Chrome and Firefox

Update:

Since the mathjax cdn is shutting down, change

<script type="text/javascript" async
  src="https://cdn.mathjax.org/mathjax/2.7-latest/MathJax.js?...">
</script>

to

<script type="text/javascript" async
  src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?...">
</script>
gaitat
  • 12,449
  • 4
  • 52
  • 76
2

as others have said you need to serve as xml for FF3, if you want to use mathml-in-html5 served as text/html you need firefox 4 (or webkit nightlies)

1

Putting your file in a filename named mml-prb.xhtml works. Note the extension.

icyrock.com
  • 27,952
  • 4
  • 66
  • 85
0

You should use xml and serve it as such (i.e. use correct mimetype), which means you have to use xhtml and mathml tags with proper namespaces. Take how W3C serves the example as an example.

Note: HTML5 is NOT xml

artificialidiot
  • 5,309
  • 29
  • 27