This specification defines the Mathematical Markup Language, or MathML. MathML is a markup language for describing mathematical notation and capturing both its structure and content. The goal of MathML is to enable mathematics to be served, received, and processed on the World Wide Web, just as [[HTML]] has enabled this functionality for text.

This specification of the markup language MathML is intended primarily for a readership consisting of those who will be developing or implementing renderers or editors using it, or software that will communicate using MathML as a protocol for input or output. It is not a User's Guide but rather a reference document.

MathML can be used to encode both mathematical notation and mathematical content. About thirty-eight of the MathML tags describe abstract notational structures, while another about one hundred and seventy provide a way of unambiguously specifying the intended meaning of an expression. Additional chapters discuss how the MathML content and presentation elements interact, and how MathML renderers might be implemented and should interact with browsers. Finally, this document addresses the issue of special characters used for mathematics, their handling in MathML, their presence in Unicode, and their relation to fonts.

While MathML is human-readable, authors typically will use equation editors, conversion programs, and other specialized software tools to generate MathML. Several versions of such MathML tools exist, both freely available software and commercial products, and more are under development.

MathML was originally specified as an XML application and most of the examples in this specification assume that syntax. Other syntaxes are possible most notably [[HTML5]] specifies the syntax for MathML in HTML. Unless explictly noted, the examples in this specification are also valid HTML syntax.

This document is an editors' copy that has no official standing. (Date: 2019-03-08)

This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at https://www.w3.org/TR/.

This document was produced by the W3C Math Working Group as a Recommendation and is part of the W3C Math Activity. The goals of the W3C Math Working Group are discussed in the W3C Math WG Charter (revised July 2006). The authors of this document are the W3C Math Working Group members. A list of participants in the W3C Math Working Group is available.

This document has been reviewed by W3C Members, by software developers, and by other W3C groups and interested parties, and is endorsed by the Director as a W3C Recommendation. It is a stable document and may be used as reference material or cited from another document. W3C's role in making the Recommendation is to draw attention to the specification and to promote its widespread deployment. This enhances the functionality and interoperability of the Web.

All reported errata to the first edition have been addressed in this addition, and a full change log appears in Appendix F Changes. The diff-marked version linked in the frontmatter highlights all changes between the first and second editions. In addition to incorporating errata, the main change in this addition is to recognise that MathML parsing is also specified in [HTML5] and where necessary to note where HTML and XML usage differ.

The Working Group maintains a comprehensive Test Suite. This is publicly available and developers are encouraged to submit their results for display. The Test Results are public. They show at least two interoperable implementations for each essential test. Further details may be found in the Implementation Report.

The MathML 2.0 (Second Edition) specification has been a W3C Recommendation since 2001. After its recommendation, a W3C Math Interest Group collected reports of experience with the deployment of MathML and identified issues with MathML that might be ameliorated. The rechartering of a Math Working Group did not signal any change in the overall design of MathML. The major additions in MathML 3 are support for bidirectional layout, better linebreaking and explicit positioning, elementary math notations, and a new strict content MathML vocabulary with well-defined semantics. The MathML 3 Specification has also been restructured.

This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.

Public discussion of MathML and issues of support through the W3C for mathematics on the Web takes place on the public mailing list of the Math Working Group (list archives). To subscribe send an email to www-math-request@w3.org with the word subscribe in the subject line. Alternatively, report an issue at this specification's GitHub repository.

The basic chapter structure of this document is based on the earlier MathML 2.0 Recommendation [MathML2]. That MathML 2.0 itself was a revision of the earlier W3C Recommendation MathML 1.01 [MathML1]; MathML 3.0 is a revision of the W3C Recommendation MathML 2.0. It differs from it in that all previous chapters have been updated, some new elements and attributes added and some deprecated. Much has been moved to separate documents containing explanatory material, material on characters and entities and on the MathML DOM. The discussion of character entities has led to the document XML Entity Definitions for Characters [Entities], which is now a W3C Recommendation. The concern with use of CSS with MathML has led to the document A MathML for CSS Profile [MathMLforCSS], which was a W3C Recommendation accompanying MathML 3.0.

The biggest differences from MathML 2.0 (Second Edition) are in Chapters 4 and 5, although there have been smaller improvements throughout the specification. A more detailed description of changes from the previous Recommendation follows.

Parsing MathML

Using the RelaxNG Schema for Mathml4

MathML documents should be validated using the RelaxNG Schema for MathML, either in the XML encoding (http://www.w3.org/Math/RelaxNG/mathml4/mathml4.rng) or in compact notation (http://www.w3.org/Math/RelaxNG/mathml4/mathml4.rnc) which is also shown below.

In contrast to DTDs there is no in-document method to associate a RelaxNG schema with a document.

We provide five RelaxNG schema for Mathml4 in five parts:

Full MathML

The RelaxNG schema for full MathML builds on the schema describing the various parts of the language which are given in the following sections. It can be found at http://www.w3.org/Math/RelaxNG/mathml4/mathml4.rnc.


         

Elements Common to Presentation and Content MathML


         

The Grammar for Presentation MathML


         
         

The Grammar for Strict Content Mathml4

The grammar for Strict Content Mathml4 can be found at http://www.w3.org/Math/RelaxNG/mathml4/mathml4-strict-content.rnc.


         

The Grammar for Content MathML

The grammar for Content Mathml4 builds on the grammar for the Strict Content MathML subset, and can be found at http://www.w3.org/Math/RelaxNG/mathml4/mathml4-content.rnc.


         
         

MathML as a module in a RelaxNG Schema

Normally, a MathML expression does not constitute an entire XML document. MathML is designed to be used as the mathematics fragment of larger markup languages. In particular it is designed to be used as a module in documents marked up with the XHTML family of markup languages. As RelaxNG directly supports modular development, this is usually very easy: an XHTML+MathML schema can be specified as simply as

# A RelaxNG Schema for  XHTML+MathML
include "xhtml.rnc"
math = external "mathml4.rnc"
Inline.class |= math
Block.class |= math
assuming that we have access to a modular RelaxNG schema for XHTML that uses Inline.class and Block.class to collect the the content models for inline and block-level elements.

Customizing the Mathml4 schema so that we can restrict the content of annotation-xml elements is similarly simple, for example:

# A RelaxNG Schema for MathML with OpenMath3 annotations
omobj = external "openmath3.rnc" 
include "mathml4.rnc" {anotation-xml.model = omobj}

The Mathml4 schema is organized so that subsetting to one of the sublanguages specified here is easy. To include strict content Mathml4 in a schema just include

include "mathml4-common.rnc"
include "mathml4-strict-content.rnc"
instead of include mathml4.rnc.

For details about RelaxNG grammars and modularization see [[RELAX-NG]] or [[RelaxNGBook]].

Using the RelaxNG Schema for Mathml4

MathML documents should be validated using the RelaxNG Schema for MathML, either in the XML encoding (http://www.w3.org/Math/RelaxNG/mathml4/mathml4.rng) or in compact notation (http://www.w3.org/Math/RelaxNG/mathml4/mathml4.rnc) which is also shown below.

In contrast to DTDs there is no in-document method to associate a RelaxNG schema with a document.

We provide five RelaxNG schema for Mathml4 in five parts:

Full MathML

The RelaxNG schema for full MathML builds on the schema describing the various parts of the language which are given in the following sections. It can be found at http://www.w3.org/Math/RelaxNG/mathml4/mathml4.rnc.


         

Elements Common to Presentation and Content MathML


         

The Grammar for Presentation MathML


         
         

The Grammar for Strict Content Mathml4

The grammar for Strict Content Mathml4 can be found at http://www.w3.org/Math/RelaxNG/mathml4/mathml4-strict-content.rnc.


         

The Grammar for Content MathML

The grammar for Content Mathml4 builds on the grammar for the Strict Content MathML subset, and can be found at http://www.w3.org/Math/RelaxNG/mathml4/mathml4-content.rnc.


         
         

MathML as a module in a RelaxNG Schema

Normally, a MathML expression does not constitute an entire XML document. MathML is designed to be used as the mathematics fragment of larger markup languages. In particular it is designed to be used as a module in documents marked up with the XHTML family of markup languages. As RelaxNG directly supports modular development, this is usually very easy: an XHTML+MathML schema can be specified as simply as

# A RelaxNG Schema for  XHTML+MathML
include "xhtml.rnc"
math = external "mathml4.rnc"
Inline.class |= math
Block.class |= math
assuming that we have access to a modular RelaxNG schema for XHTML that uses Inline.class and Block.class to collect the the content models for inline and block-level elements.

Customizing the Mathml4 schema so that we can restrict the content of annotation-xml elements is similarly simple, for example:

# A RelaxNG Schema for MathML with OpenMath3 annotations
omobj = external "openmath3.rnc" 
include "mathml4.rnc" {anotation-xml.model = omobj}

The Mathml4 schema is organized so that subsetting to one of the sublanguages specified here is easy. To include strict content Mathml4 in a schema just include

include "mathml4-common.rnc"
include "mathml4-strict-content.rnc"
instead of include mathml4.rnc.

For details about RelaxNG grammars and modularization see [[RELAX-NG]] or [[RelaxNGBook]].