HTML5 MathML

HTML5 MathML <mfrac> Tag

The <mfrac> tag builds a fraction from exactly two children: the numerator, followed by the denominator. It draws a horizontal fraction bar between them.


Definition and usage

The <mfrac> element takes two child expressions and stacks them vertically with a fraction bar. The first child becomes the numerator and the second the denominator. The optional linethickness attribute controls the thickness of the bar; setting it to 0 produces a fraction without a visible line (useful for binomial coefficients).

Syntax

<mfrac linethickness="1">
  <!-- numerator -->
  <!-- denominator -->
</mfrac>

Example

The fraction one over two
<math>
  <mfrac>
    <mn>1</mn>
    <mn>2</mn>
  </mfrac>
</math>

This renders 1 over 2 with a horizontal bar between them. Wrap multi-term numerators or denominators in <mrow> so they are treated as single units, for example <mrow><mi>a</mi><mo>+</mo><mi>b</mi></mrow>.

ℹ️

The <mfrac> element is part of MathML Core and is supported in all modern browsers, including Chrome and Edge from version 109 onward.

Ready to use your HTML skills?

Find web development internships and fresher jobs across India.

Browse Web Dev Internships