<mstyle>

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2023.

* Some parts of this feature may have varying levels of support.

The <mstyle> MathML element is used to change the style of its children.

Note: Historically, this element accepted almost all the MathML attributes and it was used to override the default attribute values of its descendants. It was later restricted to only a few relevant styling attributes that were used in existing web pages. Nowadays, these styling attributes are common to all MathML elements and so <mstyle> is really just equivalent to an <mrow> element. However, <mstyle> may still be relevant for compatibility with MathML implementations outside browsers.

Attributes

This element's attributes include the global MathML attributes as well as the following deprecated attributes:

background

Use CSS property background-color instead.

color

Use CSS property color instead.

fontsize

Use CSS property font-size instead.

fontstyle

Use CSS property font-style instead.

fontweight

Use CSS property font-weight instead.

Examples

Attributes mapped to CSS

The following example uses global attributes displaystyle and mathcolor to respectively override the math-style and color of the <munder> and <munderover> children:

html
<math display="block">
  <mstyle displaystyle="false" mathcolor="teal">
    <munder>
      <mo>∑</mo>
      <mi>I</mi>
    </munder>
    <munderover>
      <mo>∏</mo>
      <mrow>
        <mi>i</mi>
        <mo>=</mo>
        <mn>1</mn>
      </mrow>
      <mi>N</mi>
    </munderover>
  </mstyle>
</math>

Legacy script attributes

The following example shows a formula with font-size set to 128pt. It contains numbers that are placed in nested superscripts as well as an <mstyle> element with legacy attributes scriptsizemultiplier and scriptminsize. The font-size is multiplied by 0.5 when entering each superscript as long as that does not make it smaller than 16pt.

html
<math display="block">
  <mstyle scriptsizemultiplier="0.5" scriptminsize="16pt">
    <msup>
      <mn>2</mn>
      <msup>
        <mn>2</mn>
        <msup>
          <mn>2</mn>
          <msup>
            <mn>2</mn>
            <msup>
              <mn>2</mn>
              <msup>
                <mn>2</mn>
                <mn>2</mn>
              </msup>
            </msup>
          </msup>
        </msup>
      </msup>
    </msup>
  </mstyle>
</math>
css
math {
  font-size: 128pt;
}

Technical summary

Implicit ARIA role None

Specifications

Specification
MathML Core
# style-change-mstyle

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
mstyle
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 – 5 (Release date: 2004-11-09)
footnote Partial support
footnote Attributes bevelled, notation, open, close, separators, accent, accentunder, selection, mathvariant are not supported.
Firefox – Full support
Firefox 6 (Release date: 2011-08-16)
footnote
footnote In Firefox 29, accepted attributes have been restricted to those actually used in practice: id, class, style, href, mathcolor, mathbackground, scriptlevel, displaystyle, scriptsizemultiplier, scriptminsize, dir, mathsize, mathvariant, fontfamily, fontweight, fontstyle, fontsize, color, background.
footnote In Firefox 103, attributes scriptsizemultiplier and scriptminsize have been removed.
Opera – Full support
Opera 95 (Release date: 2023-02-01)
footnote Full support
Safari – Full support
Safari 5.1 (Release date: 2011-07-20)
footnote Full support
Chrome Android – Full support
Chrome Android 109 (Release date: 2023-01-10)
footnote Full support
Firefox for Android – Partial support
Firefox for Android 4 – 5 (Release date: 2011-03-29)
footnote Partial support
footnote Attributes bevelled, notation, open, close, separators, accent, accentunder, selection, mathvariant are not supported.
Firefox for Android – Full support
Firefox for Android 6 (Release date: 2011-08-16)
footnote
footnote In Firefox for Android 29, accepted attributes have been restricted to those actually used in practice: id, class, style, href, mathcolor, mathbackground, scriptlevel, displaystyle, scriptsizemultiplier, scriptminsize, dir, mathsize, mathvariant, fontfamily, fontweight, fontstyle, fontsize, color, background.
footnote In Firefox for Android 103, attributes scriptsizemultiplier and scriptminsize have been removed.
Opera Android – Full support
Opera Android 74 (Release date: 2023-03-13)
footnote Full support
Safari on iOS – Full support
Safari on iOS 5 (Release date: 2011-10-12)
footnote Full 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 – Full support
WebView on iOS 5 (Release date: 2011-10-12)
footnote Full support
background
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.1 (Release date: 2011-07-20)
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 5 (Release date: 2011-10-12)
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 5 (Release date: 2011-10-12)
footnote Full support
color
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.1 (Release date: 2011-07-20)
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 5 (Release date: 2011-10-12)
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 5 (Release date: 2011-10-12)
footnote Full support
fontsize
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.1 (Release date: 2011-07-20)
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 5 (Release date: 2011-10-12)
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 5 (Release date: 2011-10-12)
footnote Full support
fontstyle
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.1 (Release date: 2011-07-20)
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 5 (Release date: 2011-10-12)
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 5 (Release date: 2011-10-12)
footnote Full support
fontweight
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.1 (Release date: 2011-07-20)
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 5 (Release date: 2011-10-12)
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 5 (Release date: 2011-10-12)
footnote Full 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.