Home / Learn HTML / HTML MathML: Maths Formulas
HTML MathML: Maths Formulas
Write fractions, powers, roots and matrices as real HTML. No images and no extra library.
Theory in plain words
What it is
MathML writes mathematical formulas as real HTML-like elements.
Why we use it
Formulas stay sharp, can be read by screen readers and copied as text.
How it works
Elements such as mfrac, msup and msqrt describe the formula and the browser draws it.
Where it is used
- Science and school sites
- Documentation with formulas
What is MathML?
MathML is a set of HTML tags for maths. The browser draws the formula, so it stays sharp, can be selected and is read by screen readers. All modern browsers support it.
mi is an identifier (a letter), mo is an operator, mn is a number.
| Tag | Meaning |
|---|---|
<math> | Wraps the formula. Use display="block" for a big centred formula. |
<mi> | A variable or name, for example x |
<mn> | A number |
<mo> | An operator: + - = ( ) |
<mrow> | Groups parts together |
<mfrac> | Fraction: top, then bottom |
<msup> <msub> | Power and subscript |
<msqrt> <mroot> | Square root and n-th root |
<munderover> | Limits, for example a sum |
<mtable> | Table or matrix |
Fractions, powers and roots
mfrac takes exactly two children: top and bottom.
mrow groups the top and the bottom so the fraction reads correctly.
Sums and matrices
mtr is a row and mtd is a cell, like a table.
math { font-size: 1.4em; color: #0b6e4f; }. For an image or screen-reader fallback add aria-label on the math tag when the formula is complex.Quick quiz
1. Which tag draws a fraction in MathML?
mfrac takes two children: the top and the bottom.
2. What does the mi tag hold?
mn is a number and mo is an operator.
3. Which tag groups parts of a formula together?
mrow groups children so they act as one unit.
Common questions
Which tag draws a fraction in MathML?
<mfrac>. mfrac takes two children: the top and the bottom.
What does the mi tag hold?
An identifier such as x. mn is a number and mo is an operator.
Which tag groups parts of a formula together?
<mrow>. mrow groups children so they act as one unit.