<mfrac>

Baseline 2023
Newly available

Since January 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

The <mfrac> MathML element is used to display fractions. It can also be used to mark up fraction-like objects such as binomial coefficients and Legendre symbols.

Syntax

html
<mfrac>numerator denominator</mfrac>

Attributes

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

denomalign Deprecated Non-standard

The alignment of the denominator under the fraction. Possible values are: left, center (default), and right.

linethickness

A <length-percentage> indicating the thickness of the horizontal fraction line.

numalign Deprecated Non-standard

The alignment of the numerator over the fraction. Possible values are: left, center (default), and right.

Note: For the linethickness attribute, some browsers may also accept the deprecated values medium, thin and thick (whose exact interpretation is left to implementers) or legacy MathML lengths.

Examples

Simple fraction

The following MathML code should render as a fraction with numerator "a + 2" and denominator "3 − b":

html
<math display="block">
  <mfrac>
    <mrow>
      <mi>a</mi>
      <mo>+</mo>
      <mn>2</mn>
    </mrow>
    <mrow>
      <mn>3</mn>
      <mo></mo>
      <mi>b</mi>
    </mrow>
  </mfrac>
</math>

Fraction without bar

The following MathML code should render as a binomial coefficient:

html
<math display="block">
  <mrow>
    <mo>(</mo>
    <mfrac linethickness="0">
      <mi>n</mi>
      <mi>k</mi>
    </mfrac>
    <mo>)</mo>
  </mrow>
</math>

Technical summary

Specifications

Specification
MathML Core
# fractions-mfrac

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
mfrac
denomalign
DeprecatedNon-standard
linethickness
Named spaces (e.g. thinmathspace to mean 3/18em)
DeprecatedNon-standard
Nonzero unitless values (e.g. 5 to mean 500% the default thickness)
DeprecatedNon-standard
thin, medium, thick values
DeprecatedNon-standard
numalign
DeprecatedNon-standard

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.
Has more compatibility info.