Français

<mfrac>

Write a fraction

  • MathML
  • accessibility
  • semantics

<mfrac> — The fraction

The <mfrac> element displays a fraction. It takes exactly two children: the numerator and the denominator, visually separated by a fraction bar.

When to use it

You want to display a fraction in a formula: a ratio, a division, a coefficient. You want the numerator/denominator structure to be readable by assistive technologies, not just a slash between two numbers.

What you gain

Accessibility: screen readers announce "fraction, numerator, denominator" in a structured way. "1 over 2" is clearer than "1 slash 2".

Code example

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

Further reading