MathML

Baseline 2023
Newly available

Since January 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

Mathematical Markup Language (MathML) is an XML-based language for describing mathematical notation.

MathML was originally designed as a general-purpose specification for browsers, office suites, computer algebra systems, EPUB readers, LaTeX-based generators. However, this approach was not very adapted to the Web: the subset focusing on semantics has never been implemented in browsers while the subset focusing on math layout led to incomplete and inconsistent browser implementations.

MathML Core is a subset with increased implementation details based on rules from LaTeX and the Open Font Format. It is tailored for browsers and designed specifically to work well with other web standards including HTML, CSS, DOM, JavaScript.

Below you will find links to documentation, examples, and tools to work with MathML. MDN uses MathML Core as a reference specification but, due to an erratic standardization history, legacy MathML features may still show up in existing implementations and web content.

Note: It is highly recommended that developers and authors switch to MathML Core, perhaps relying on other web technologies to cover missing use cases. The Math WG is maintaining a set of MathML polyfills to facilitate that transition.

Tutorials

MathML for beginners

This tutorial will guide you through creating math formulas using structured markup. It starts with an introduction to adding MathML to an HTML document, followed by a deep dive into key components: fractions and roots, scripted elements, and text containers. The tutorial then covers tabular layouts for matrices and advanced math formatting. Finally, a challenge tests your understanding by having you recreate three famous mathematical formulas using the learned concepts.

Guides

Authoring MathML

Suggestions and tips for writing MathML, including suggested MathML editors and how to integrate their output into Web content.

Fonts for MathML

How users can install such math fonts to properly display MathML in browsers.

Reference

MathML element reference

Details about each MathML element and compatibility information for desktop and mobile browsers.

MathML global attribute reference

Information about global MathML attributes applicable to all elements.

MathML attribute reference

Information about MathML attributes that modify the appearance or behavior of elements.

MathML attribute values

Further information about MathML attribute values.

Examples

Below you'll find some examples you can look at to help you to understand how to use MathML.

MathML formulas

The following demos display increasingly complex mathematical concepts in Web content.

Proving the Pythagorean theorem

Small example showing a proof of the Pythagorean Theorem.

Deriving the quadratic formula

Outlines the derivation of the Quadratic Formula.

Mozilla MathML test

Original test from the Mozilla MathML project. It contains examples from the TeXbook with image references generated by TeX.

MathML browser test

A similar test with concrete formulas taken from Wikipedia.

Other Web technologies

The following demos mix MathML with other Web technologies to produce advanced content.

<la-tex> custom element

A custom element that accepts LaTeX content.

Magnetic field demo

A 3D representation of a magnetic field, using SVG and WebGL.

Συνάρτηση ζήτα Ρήμαν (el)

A greek article about the Riemann zeta function, with Web fonts from the Greek Font Society.

Pell's equation

A JavaScript program to solve Pell's equation using BigInt.

Lovelace's program for Bernoulli numbers

An emulator for Ada Lovelace's program to calculate Bernoulli numbers, using Private properties.

Getting help from the community

Tools

Browser compatibility

BCD tables only load in the browser