scriptlevel

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

The scriptlevel global attribute sets the math-depth of a MathML element. It allows overriding rules from the user agent stylesheet that define automatic calculation of font-size within MathML formulas.

Syntax

html
<math scriptlevel="-1"> <!-- decrease math-depth by 1 -->
<math scriptlevel="+2"> <!-- increase math-depth by 2 -->
<math scriptlevel="0"> <!-- reset math-depth to 0 -->

Values

If <U> is an unsigned integer (i.e., with prefix sign symbol removed) then the accepted values are:

<U>

Sets the math-depth to value <U>. This will set font-size of the element to the same value as the one of elements at the specified depth.

+<U>

Sets the math-depth to value add(<U>). This will scale down font-size on the element <U> times.

-<U>

Sets the math-depth to value add(-<U>). This will scale up font-size on the element <U> times.

Example

html
<!-- math-depth defaults to 0 on the <math> root. -->
<math>
  <msubsup>
    <!-- math-depth and font-size remain unchanged on the base. -->
    <mtext>base</mtext>
    <!-- math-depth defaults to add(1) within the subscript, so it
         is incremented by 1 and the font-size is scaled down once. -->
    <mtext>subscript</mtext>
    <!-- math-depth defaults to add(1) within the superscript too, but
         the scriptlevel attribute tells to increment it by 2 instead,
         so the font-size is actually scaled down twice. -->
    <mtext scriptlevel="+2">superscript</mtext>
  </msubsup>
</math>

Specifications

Specification
MathML Core
# dfn-scriptlevel

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
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
No support
No support
See implementation notes.

See also