Thomas A. Alspaugh


MathML is a language for expressing mathematical notations, both their presentation (how a notation looks on a page) and their semantics or content (what a notation means).

This page presents an overview of what I have used from presentation MathML version 3.0: of the 39 elements, and a few of their attributes. For details, additional elements, and additional attributes for the elements presented here, or for content MathML, see the W3C definition [MathML 3.0]. Each discussion in this document of an element m ends with a link to m's section in the definition (→W3C definition of m).

Organization and coverage

MathML, like other recursively-defined languages, contains compound elements which contain other elements, and tokens which do not.

Overview of MathML constructs
Group Function Element Examples
Identifier mi x <mi>x</mi>
π <mi>π</mi>
sin <mi>sin</mi>
Number mn 123 <mn>123</mn>
Operator, fence,
mo + <mo>+</mo>
( <mo>(</mo>
, <mo>,</mo>
Text mtext Thus <mtext>Thus</mtext>
Space mspace <mspace width='1em' />
Horizontal expression mrow 1+2
  <mn>1</mn><mo>+</mo> <mn>2</mn>
Fenced and separated list mfenced 12
Fraction mfrac 12 <mfrac><mn>1</mn><mn>2</mn></mfrac>
Sub-, superscript msub a1 <msub><mi>a</mi><mn>1</mn></msub>
msup b2 <msup><mi>b</mi><mn>2</mn></msup>
msubsup c34
Radical msqrt 3 <msqrt><mn>3</mn></msqrt>
mroot 43 <mroot><mn>4</mn><mn>3</mn></mroot>
Tables and matrices mtable 2-1 10 a = uv b = u2 - v2 examples
Top-level element math

The following token elements are not discussed here: maction, maligngroup, malignmark, mglyph1, ms.

Token element mo is discussed here but not its use for mathematical accents.

The following compound elements are not discussed here: menclose, mlabeledtr, mlongdiv, mmultiscripts, mpadded, mphantom, mprescripts, mscarries, mscarry, msgroup, msline, mstack, mstyle, munder, mover, munderover, none.

Note that some of the elements not discussed here are not supported by most or in some cases any browsers at this writing (2019), or are poorly supported.

The namespace for MathML is

The <math> element

All MathML must be within a <math> element. (To save space, many of this page's examples do not show it.)

A <math> element may not be contained within another <math> element.

The <math> element takes several attributes (see the W3C definition of math for specifics).

Attribute Values Effect Default
display 'block'
Displays its contents' presentation as a block or inline 'inline'

The <math> element does not take the ordinary HTML attributes such as class and style.

→W3C definition of math

Token elements

Identifiers: mi

<mi>S</mi> presents identifier S, which can be a single letter or other character or a sequence of them.

Not obvious

Function names like sin should be presented with mi. (See the function application operator.)

Symbolic constants should be presented with mi; here are some examples:

Sym. UTF-8 for it In MathML
Oct &# Hex &#x
π &#960; &#x3C0; <mi> &pi; </mi>
&#8519; &#x2147; <mi> &#8519;<!--DOUBLE-STRUCK ITALIC SMALL E--> </mi>
&#8520; &#x2148; <mi> &#8520;<!--DOUBLE-STRUCK ITALIC SMALL I--> </mi>
&#8230; &#x2026; <mi> &hellip; </mi>

A horizontal ellipsis as an element in a list should be presented with mi.

→W3C definition of mi

Numbers: mn

<mn>12</mn> presents the number 12.

→W3C definition of mn

Operators, fences, and separators: mo

According to the W3C specification, mo is used for so many kinds of things because operators required sophisticated rendering and it was too tempting to reuse mo for other things that needed similar sophistication, namely fences, separators, and (not discussed here) mathematical accents.

→W3C definition of mo

Operator In MathML
- <mo>-</mo>
> <mo>&gt;</mo>
=> <mo>=&gt;</mo>
.NOT. <mo>.NOT.</mo>


<mo>o</mo> presents operator o, of one or more characters, with appropriate spacing, font size, etc.

Not obvious

Sym. utf-8 for it In MathML
Oct &# Hex &#x
&#8289; &#x2061; <mo>&ApplyFunction;</mo>
&#8290; &#x2062; <mo>&InvisibleTimes;</mo>
&#8292; &#x2064; <mo>&#8292;<!--INVISIBLE PLUS--></mo>


mo also presents fences such as ( and ).

( a+b ) using mrow for subexpression a+b:

Note that a+b may be equivalently presented using mfenced:

The fence='true' attribute should be given for fences that are not single ‘ ’ or double “ ” quotes, parentheses ( ), square brackets [ ], curly braces { }, absolute value bars | |, or any of about four dozen more listed in MathML's operator dictionary.


mo also presents separators such as commas.

Not obvious

The separator='true' attribute should be given for any separator other than comma, semicolon, or the invisible separator (&InvisibleComma;); see MathML's operator dictionary.

Sym. utf-8 for it In MathML
Oct &# Hex &#x
invisible separator
(invisible comma)
&#8291; &#x2063; <mo>&InvisibleComma;</mo>
a 12 as for an array element in the first row and second column, presented using msub and mrow:

Text: mtext

<mtext>Commentary text</mtext> presents text Commentary text.

→W3C definition of mtext

Space: mspace

<mspace width='1em' /> presents 1em of whitespace .

Widths may also be given in units of px, cm, mm, pt, and several others.

→W3C definition of mspace

Compound elements

Compound elements group mathematical subexpressions in useful ways.

Horizontally-grouped subexpressions: mrow

An mrow element groups its contents in a horizontal row, spaced appropriately as determined by what its contents are.

An mrow may contain other mrows (or other compound elements), and in fact often should. Each subexpression within an mrow should be contained in its own nested mrow. Each operator should be placed in its own mrow along with its operand(s), with the exception that a sequence of operators of the same precedence2 and their operands may be placed in a single mrow (for example, addition and subtraction may share an mrow, or multiplication and division, but not addition and multiplication).

a ( b+c ) = a b + a c

Each of these is a subexpression and should be in its own mrow:

  • b+c
  • ( b+c )
  • a ( b+c )
  • a b
  • a c
  • a b + a c

Several other MathML elements present their contents as if enclosed in an mrow:

and others not covered by this web page but described in the W3C definition §

→W3C definition of mrow

Horizontally-grouped subexpressions inside a pair of fences and separated by commas or other separators: mfenced

An mfenced element groups its contents in a horizontal row, separated by commas and enclosed in parentheses.

Different separators (or none) and different fences (or none) may be specified using attributes. With no separators and no fences, mfenced has the same effect as mrow.

Attribute Value type Effect of its value Default
open String The opening fence (
close String The closing fence )
separators String The separator character(s); if more than one is given, they are used in sequence ,

abc <math><mfenced><mi>a</mi><mi>b</mi><mi>c</mi></mfenced></math>

  <mfenced open='[' close=']' separators=':,'>
max def
  <mo>&#8289;<!--function application--></mo>

→W3C definition of mfenced

Fractions: mfrac

<mfrac>ND</mfrac> presents the fraction with numerator N and denominator D.

The fraction is presented with a horizontal fraction bar, or with a slanted fraction bar if the attribute bevelled='true' is given.

π2 <math><mfrac><mi>&#960;<!--SMALL PI--></mi><mn>2</mn></mfrac></math>

    <mfrac bevelled='true'>

→W3C definition of mfrac

Sub- and superscripts: msub, msup, msubsup

Subscripts: msub

<msub>EB</msub> presents subexpression E with subscript B.

a1 <math><msub><mi>a</mi> <mn>1</mn></msub></math>

→W3C definition of msub

Superscripts: msup

<msub>EP</msub> presents subexpression E with superscript P.

b 2 d

→W3C definition of msup

Both sub- and superscripts: msubsup

<msubsup>EBP</msubsup> presents subexpression E with subscript B and superscript P.


→W3C definition of msubsup

Radicals: msqrt, mroot

Square roots: msqrt

<msqrt>E</msqrt> presents the square root of subexpression E.

b2 - 4 a c

→W3C definition of msqrt

Roots in general: mroot

<mroot>EN</mroot> presents the Nth root of subexpression E.

34 <math><mroot><mn>3</mn><mn>4</mn></mroot></math>

→W3C definition of mroot

Tables and matrices: mtable, mtr, mtd

The mtable element presents a table, a matrix, or subexpressions whose layout can be specified in tabular form.

Analogous to an HTML table, an mtable element contains one or more mtr elements presenting the table's rows; each mtr element contains one or more mtd elements presenting the table's cells.

2-1 10
a = uv b = u2 - v2
    <mtable side='right'>

→W3C definition of mtable, mtr, mtd

Common attributes

Of any element

Attribute Value type Effect of its value Default
class String Associates the style class(es) with the element none
style String Associates the style information with the element none
href URI Makes the element a hyperlink none

See [MathML 3.0] Using CSS with MathML to use class or style intelligently.

Elements also accept the id and xref attributes (for cross-referencing presentation and content elements), not discussed here.

Of any presentation element

Attribute Value type Effect of its value Default
mathcolor color Sets the element's color inherited
mathbackgroundcolor color Sets the element's background color transparent

Colors may be #RGB, #RRGGBB, or an HTML color name.

Of any token element

Attribute Value type Effect of its value Default
mathvariant normal, bold, italic, double-struck, script, sans-serif, twelve others Sets the element's font type normal (except for mi)
mathsize small normal big length Sets the element's size inherited

Token elements also accept the dir attribute, not discussed here.


  1. MathML allows mglyph, which presents a nonstandard character using an image, to appear in mi, mn, mo, and mtext elements while still classifying them as token elements.
  2. The precedence of two operators expresses which of them binds more tightly and thus which one is performed first during evaluation of an expression containing them. For example, multiplication is said to bind more tightly than addition, so the expression

    2 × 3 + 4 × 5

    is evaluated in the sequence multiplications then addition

    2 × 3 + 4 × 5 = 2 × 3 + 4 × 5 = 6 + 20 = 26

    rather than addition then multiplications

    2 × 3 + 4 × 5 2 × 3 + 4 × 5 = 2 × 7 × 5 = 70

    In contrast, addition and subtraction are said to bind with equal tightness. In such cases the operations are typically performed left-to-right, so that

    Precedence Operators
    20 ( )
    40 ,
    invisible comma
    230 ∀, ∃
    240 ∈, ⊂, ⊃
    243 >
    245 <
    260 =
    265 ∙ /
    275 − +
    390 invisible times
    880 invisible plus

    1 + 2 - 3 + 4

    is evaluated

    1 + 2 - 3 + 4 = 3 - 3 + 4 = 0 + 4 = 4

    Operations may be listed in a total order by precedence, that is to say, for any two operators a and b, either a binds more tightly than b, b binds more tightly than a, or a and b bind equally tightly. Consequently the precedence of each in a set of operators is expressed as an integer. By custom, smaller integers mean tighter binding. and larger, less-tight.

    The operator precedences for MathML are listed in a very, very long table, from which a dozen or so common operators have been drawn and appear in the brief table at right. (I don't know why multiplication seems to have been given two different precedences, one for ∙ and the other for invisible times.)


Mathematical Markup Language (MathML) Version 3.0 2nd Edition. W3C Recommendation 10 April 2014.

check internal links

flip bgunflip