MathML global attributes

Global attributes are attributes common to all MathML elements; they can be used on all elements, though they may have no effect on some elements.

Global attributes may be specified on all MathML elements, even those not specified in the standard. That means that any non-standard elements must still permit these attributes, even though using those elements means that the document is no longer MathML-compliant.

In addition to the basic MathML global attributes, the following global attributes also exist:

  • The event handler attributes such as onclick, onfocus, etc.
  • The href attribute for making MathML element a hyperlink.

List of global attributes

autofocus

A boolean attribute that indicates that the element should be focused on page load.

class

A space-separated list of the classes of the element. Classes allow CSS and JavaScript to select and access specific elements via the class selectors or functions like the method Document.getElementsByClassName().

data-*

Forms a class of attributes, called custom data attributes, that allow proprietary information to be exchanged between the MathML and its DOM representation that may be used by scripts. All such custom data are available via the MathMLElement interface of the element the attribute is set on. The MathMLElement.dataset property gives access to them.

dir

An enumerated attribute indicating the directionality of the MathML element. It can have the following values:

  • ltr, which means left to right and is used to render mathematical expressions from the left to the right (e.g., English or Moroccan style);
  • rtl, which means right to left and is used to render mathematical expressions from the right to the left (e.g., Maghreb or Machrek style);
displaystyle:

A boolean setting the math-style for the element.

  • true, which means normal.
  • false, which means compact.
id

Defines a unique identifier (ID) which must be unique in the whole document. Its purpose is to identify the element when linking (using a fragment identifier), scripting, or styling (with CSS).

mathbackground

A background-color for the element.

mathcolor

A color for the element.

mathsize

A <length-percentage> used as a font-size for the element.

nonce

A cryptographic nonce ("number used once") which can be used by Content Security Policy to determine whether a given fetch will be allowed to proceed.

scriptlevel

Specifies a math-depth for the element. See the scriptlevel page for accepted values and mapping.

style

Contains CSS styling declarations to be applied to the element. Note that it is recommended for styles to be defined in a separate file or files. This attribute and the <style> element have mainly the purpose of allowing for quick styling, for example for testing purposes.

tabindex

An integer attribute indicating if the element can take input focus (is focusable), if it should participate to sequential keyboard navigation, and if so, at what position. It can take several values:

  • a negative value means that the element should be focusable, but should not be reachable via sequential keyboard navigation;
  • 0 means that the element should be focusable and reachable via sequential keyboard navigation, but its relative order is defined by the platform convention;
  • a positive value means that the element should be focusable and reachable via sequential keyboard navigation; the order in which the elements are focused is the increasing value of the tabindex. If several elements share the same tabindex, their relative order follows their relative positions in the document.

Specifications

Specification
MathML Core
# dfn-scriptlevel
MathML Core
# dfn-displaystyle
MathML Core
# layout-of-operators
MathML Core
# dfn-mathbackground
MathML Core
# dfn-mathsize
MathML Core
# dfn-mathcolor
MathML Core
# dfn-dir

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
dir
Chrome – Full support
Chrome 109 (Release date: 2023-01-10)
footnote Full support
Edge – Full support
Edge 109 (Release date: 2023-01-12)
footnote Full support
Firefox – Full support
Firefox 70 (Release date: 2019-10-22)
footnote
footnote Prior to Firefox 70, the attribute was only accepted on a few elements, as specified in MathML 3.
footnote See https://hg.mozilla.org/mozilla-central/rev/3b30c8db537c
Opera – Full support
Opera 95 (Release date: 2023-02-01)
footnote Full support
Safari – Full support
Safari 8 (Release date: 2014-10-16)
footnote
footnote See https://trac.webkit.org/changeset/159504
Chrome Android – Full support
Chrome Android 109 (Release date: 2023-01-10)
footnote Full support
Firefox for Android – Full support
Firefox for Android 79 (Release date: 2020-07-28)
footnote
footnote Prior to Firefox for Android 79, the attribute was only accepted on a few elements, as specified in MathML 3.
footnote See https://hg.mozilla.org/mozilla-central/rev/3b30c8db537c
Opera Android – Full support
Opera Android 74 (Release date: 2023-03-13)
footnote Full support
Safari on iOS – Full support
Safari on iOS 8 (Release date: 2014-09-17)
footnote
footnote See https://trac.webkit.org/changeset/159504
Samsung Internet – Full support
Samsung Internet 21 (Release date: 2023-05-19)
footnote Full support
WebView Android – Full support
WebView Android 109 (Release date: 2023-01-10)
footnote Full support
WebView on iOS – Full support
WebView on iOS 8 (Release date: 2014-09-17)
footnote
footnote See https://trac.webkit.org/changeset/159504
Mirrors MathML operators in RTL, and stretches operators and grouping symbols
Chrome – Full support
Chrome 144 (Release date: 2026-01-13)
footnote Full support
Edge – Full support
Edge 144 (Release date: 2026-01-21)
footnote Full support
Firefox – Full support
Firefox 146 (Release date: 2025-12-09)
footnote Full support
Opera – Full support
Opera 128 (Release date: 2026-02-26)
footnote Full support
Safari – No support
Safari
footnote No support
Chrome Android – Full support
Chrome Android 144 (Release date: 2026-01-13)
footnote Full support
Firefox for Android – Full support
Firefox for Android 146 (Release date: 2025-12-09)
footnote Full support
Opera Android – Full support
Opera Android 95 (Release date: 2026-02-11)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – Full support
WebView Android 144 (Release date: 2026-01-13)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote No support
displaystyle
Chrome – Full support
Chrome 109 (Release date: 2023-01-10)
footnote Full support
Edge – Full support
Edge 109 (Release date: 2023-01-12)
footnote Full support
Firefox – Full support
Firefox 83 (Release date: 2020-11-17)
footnote
footnote Prior to Firefox 83, the attribute was only accepted on a few elements, as specified in MathML 3, and was not implemented via math-style.
footnote See https://hg.mozilla.org/mozilla-central/rev/60a72a6c7c1d
Opera – Full support
Opera 95 (Release date: 2023-02-01)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote
footnote Since Safari 14.1, this attribute is implemented via math-style.
footnote See https://trac.webkit.org/changeset/267578
Chrome Android – Full support
Chrome Android 109 (Release date: 2023-01-10)
footnote Full support
Firefox for Android – Full support
Firefox for Android 83 (Release date: 2020-11-17)
footnote
footnote Prior to Firefox for Android 83, the attribute was only accepted on a few elements, as specified in MathML 3, and was not implemented via math-style.
footnote See https://hg.mozilla.org/mozilla-central/rev/60a72a6c7c1d
Opera Android – Full support
Opera Android 74 (Release date: 2023-03-13)
footnote Full support
Safari on iOS – Full support
Safari on iOS 14 (Release date: 2020-09-16)
footnote
footnote Since Safari on iOS 14.1, this attribute is implemented via math-style.
footnote See https://trac.webkit.org/changeset/267578
Samsung Internet – Full support
Samsung Internet 21 (Release date: 2023-05-19)
footnote Full support
WebView Android – Full support
WebView Android 109 (Release date: 2023-01-10)
footnote Full support
WebView on iOS – Full support
WebView on iOS 14 (Release date: 2020-09-16)
footnote
footnote Since WebView on iOS 14.1, this attribute is implemented via math-style.
footnote See https://trac.webkit.org/changeset/267578
href
Non-standard
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 7 (Release date: 2011-09-27)
footnote
footnote See https://hg.mozilla.org/mozilla-central/rev/12294b20e4d9
Opera – No support
Opera
footnote No support
Safari – Full support
Safari 10 (Release date: 2016-09-20)
footnote
footnote See https://trac.webkit.org/changeset/203104
Chrome Android – No support
Chrome Android
footnote No support
Firefox for Android – Full support
Firefox for Android 7 (Release date: 2011-09-27)
footnote
footnote See https://hg.mozilla.org/mozilla-central/rev/12294b20e4d9
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – Full support
Safari on iOS 10 (Release date: 2016-09-13)
footnote
footnote See https://trac.webkit.org/changeset/203104
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – Full support
WebView on iOS 10 (Release date: 2016-09-13)
footnote
footnote See https://trac.webkit.org/changeset/203104
mathbackground
Deprecated
Chrome – Full support
Chrome 109 (Release date: 2023-01-10)
footnote Full support
Edge – Full support
Edge 109 (Release date: 2023-01-12)
footnote Full support
Firefox – Full support
Firefox 70 (Release date: 2019-10-22)
footnote
footnote Prior to Firefox 70, the attribute was only accepted on a few elements, as specified in MathML 3.
footnote See https://hg.mozilla.org/mozilla-central/rev/3b30c8db537c
Opera – Full support
Opera 95 (Release date: 2023-02-01)
footnote Full support
Safari – Full support
Safari 5 (Release date: 2010-06-07)
footnote
footnote See https://trac.webkit.org/changeset/62968
Chrome Android – Full support
Chrome Android 109 (Release date: 2023-01-10)
footnote Full support
Firefox for Android – Full support
Firefox for Android 79 (Release date: 2020-07-28)
footnote
footnote Prior to Firefox for Android 79, the attribute was only accepted on a few elements, as specified in MathML 3.
footnote See https://hg.mozilla.org/mozilla-central/rev/3b30c8db537c
Opera Android – Full support
Opera Android 74 (Release date: 2023-03-13)
footnote Full support
Safari on iOS – Full support
Safari on iOS 4 (Release date: 2010-06-21)
footnote
footnote See https://trac.webkit.org/changeset/62968
Samsung Internet – Full support
Samsung Internet 21 (Release date: 2023-05-19)
footnote Full support
WebView Android – Full support
WebView Android 109 (Release date: 2023-01-10)
footnote Full support
WebView on iOS – Full support
WebView on iOS 4 (Release date: 2010-06-21)
footnote
footnote See https://trac.webkit.org/changeset/62968
mathcolor
Deprecated
Chrome – Full support
Chrome 109 (Release date: 2023-01-10)
footnote Full support
Edge – Full support
Edge 109 (Release date: 2023-01-12)
footnote Full support
Firefox – Full support
Firefox 70 (Release date: 2019-10-22)
footnote
footnote Prior to Firefox 70, the attribute was only accepted on a few elements, as specified in MathML 3.
footnote See https://hg.mozilla.org/mozilla-central/rev/3b30c8db537c
Opera – Full support
Opera 95 (Release date: 2023-02-01)
footnote Full support
Safari – Full support
Safari 5 (Release date: 2010-06-07)
footnote
footnote See https://trac.webkit.org/changeset/62968
Chrome Android – Full support
Chrome Android 109 (Release date: 2023-01-10)
footnote Full support
Firefox for Android – Full support
Firefox for Android 79 (Release date: 2020-07-28)
footnote
footnote Prior to Firefox for Android 79, the attribute was only accepted on a few elements, as specified in MathML 3.
footnote See https://hg.mozilla.org/mozilla-central/rev/3b30c8db537c
Opera Android – Full support
Opera Android 74 (Release date: 2023-03-13)
footnote Full support
Safari on iOS – Full support
Safari on iOS 4 (Release date: 2010-06-21)
footnote
footnote See https://trac.webkit.org/changeset/62968
Samsung Internet – Full support
Samsung Internet 21 (Release date: 2023-05-19)
footnote Full support
WebView Android – Full support
WebView Android 109 (Release date: 2023-01-10)
footnote Full support
WebView on iOS – Full support
WebView on iOS 4 (Release date: 2010-06-21)
footnote
footnote See https://trac.webkit.org/changeset/62968
mathsize
Deprecated
Chrome – Full support
Chrome 109 (Release date: 2023-01-10)
footnote Full support
Edge – Full support
Edge 109 (Release date: 2023-01-12)
footnote Full support
Firefox – Partial support
Firefox 1 – 69 (Release date: 2004-11-09)
footnote Partial support
footnote Attribute only accepted on a few elements, as specified in MathML 3.
Firefox – Full support
Firefox 70 (Release date: 2019-10-22)
footnote
footnote See https://hg.mozilla.org/mozilla-central/rev/3b30c8db537c
Opera – Full support
Opera 95 (Release date: 2023-02-01)
footnote Full support
Safari – Full support
Safari 5 (Release date: 2010-06-07)
footnote
footnote See https://trac.webkit.org/changeset/63079
Chrome Android – Full support
Chrome Android 109 (Release date: 2023-01-10)
footnote Full support
Firefox for Android – Partial support
Firefox for Android 4 – 68 (Release date: 2011-03-29)
footnote Partial support
footnote Attribute only accepted on a few elements, as specified in MathML 3.
Firefox for Android – Full support
Firefox for Android 79 (Release date: 2020-07-28)
footnote
footnote See https://hg.mozilla.org/mozilla-central/rev/3b30c8db537c
Opera Android – Full support
Opera Android 74 (Release date: 2023-03-13)
footnote Full support
Safari on iOS – Full support
Safari on iOS 4.2 (Release date: 2010-11-22)
footnote
footnote See https://trac.webkit.org/changeset/63079
Samsung Internet – Full support
Samsung Internet 21 (Release date: 2023-05-19)
footnote Full support
WebView Android – Full support
WebView Android 109 (Release date: 2023-01-10)
footnote Full support
WebView on iOS – Full support
WebView on iOS 4.2 (Release date: 2010-11-22)
footnote
footnote See https://trac.webkit.org/changeset/63079
Named spaces (e.g. thinmathspace to mean 3/18em)
Deprecated Non-standard
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 1 (Release date: 2004-11-09)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – Full support
Safari 10 (Release date: 2016-09-20)
footnote Full support
Chrome Android – No support
Chrome Android
footnote No support
Firefox for Android – Full support
Firefox for Android 4 (Release date: 2011-03-29)
footnote Full support
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – Full support
Safari on iOS 10 (Release date: 2016-09-13)
footnote Full support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – Full support
WebView on iOS 10 (Release date: 2016-09-13)
footnote Full support
Nonzero unitless values (e.g. 5 to mean 500%)
Deprecated Non-standard
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – No support
Firefox 1 – 69 (Release date: 2004-11-09)
footnote Removed in 70 and later
Opera – No support
Opera
footnote No support
Safari – Full support
Safari 10 (Release date: 2016-09-20)
footnote Full support
Chrome Android – No support
Chrome Android
footnote No support
Firefox for Android – No support
Firefox for Android 4 – 68 (Release date: 2011-03-29)
footnote Removed in 79 and later
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – Full support
Safari on iOS 10 (Release date: 2016-09-13)
footnote Full support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – Full support
WebView on iOS 10 (Release date: 2016-09-13)
footnote Full support
small, normal, big values
Deprecated Non-standard
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – No support
Firefox 1 – 82 (Release date: 2004-11-09)
footnote Removed in 83 and later
Opera – No support
Opera
footnote No support
Safari – Full support
Safari 5 (Release date: 2010-06-07)
footnote Full support
Chrome Android – No support
Chrome Android
footnote No support
Firefox for Android – No support
Firefox for Android 4 – 82 (Release date: 2011-03-29)
footnote Removed in 83 and later
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – Full support
Safari on iOS 4.2 (Release date: 2010-11-22)
footnote Full support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – Full support
WebView on iOS 4.2 (Release date: 2010-11-22)
footnote Full support
scriptlevel
Chrome – Full support
Chrome 109 (Release date: 2023-01-10)
footnote Full support
Edge – Full support
Edge 109 (Release date: 2023-01-12)
footnote Full support
Firefox – Full support
Firefox 70 (Release date: 2019-10-22)
footnote
footnote Prior to Firefox 70, the attribute was only accepted on a few elements, as specified in MathML 3.
footnote Implementation does not rely on the CSS approach described in MathML Core (via math-depth and font-size: math).
footnote See https://hg.mozilla.org/mozilla-central/rev/3b30c8db537c
Opera – Full support
Opera 95 (Release date: 2023-02-01)
footnote Full support
Safari – No support
Safari
footnote No support
Chrome Android – Full support
Chrome Android 109 (Release date: 2023-01-10)
footnote Full support
Firefox for Android – Full support
Firefox for Android 79 (Release date: 2020-07-28)
footnote
footnote Prior to Firefox for Android 79, the attribute was only accepted on a few elements, as specified in MathML 3.
footnote Implementation does not rely on the CSS approach described in MathML Core (via math-depth and font-size: math).
footnote See https://hg.mozilla.org/mozilla-central/rev/3b30c8db537c
Opera Android – Full support
Opera Android 74 (Release date: 2023-03-13)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – Full support
Samsung Internet 21 (Release date: 2023-05-19)
footnote Full support
WebView Android – Full support
WebView Android 109 (Release date: 2023-01-10)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support
Non-standard. Check cross-browser support before using.
Deprecated. Not for use in new websites.
See implementation notes.
Has more compatibility info.

See also

  • Element interface that allows querying most global attributes.