MDN self-hosted library · e01.org

mathsize

The mathsize global attribute sets the font-size of a MathML element.

no runnable cells mathml-attribute upstream source

The mathsize global attribute sets the font-size of a MathML element.

[!NOTE] Use CSS for styling MathML whenever possible. The mathsize attribute should only be included for applications that are not CSS-aware and will be overridden by the CSS font-size property, if set.

Example

```css hidden html, body { height: 100%; }

body { display: grid; place-items: center; }


```html
<math display="block">
  <msup mathsize="16px">
    <mi>a</mi>
    <mn>2</mn>
  </msup>
  <mo>+</mo>
  <msup mathsize="24px">
    <mi>b</mi>
    <mn>2</mn>
  </msup>
  <mo>=</mo>
  <msup mathsize="32px">
    <mi>c</mi>
    <mn>2</mn>
  </msup>
</math>

Syntax

<!-- <length> values -->
<math mathsize="12px">
<math mathsize="0.8em">

<!-- <percentage> values -->
<math mathsize="80%">

Values

  • <length>
  • : A positive <length> value. For most font-relative units (such as em and ex), the font size is relative to the parent element's font size.

  • <percentage>

  • : A positive <percentage> value, relative to the parent element's font size.

[!NOTE] Some browsers may also accept legacy MathML lengths.

Specifications

  • In MathML 3 and earlier versions, keywords small, normal, and big as well as the MathML3-specific syntax for lengths was supported. Since MathML Core, the syntax matches CSS <length-percentage> values.

  • This attribute was designed for MathML applications that are not CSS-aware. Since MathML Core, the use of equivalent CSS is recommended instead.

Browser compatibility

See also