MyInternships.in

HTML5 MathML

HTML5 MathML <mfenced> Tag

The <mfenced> element automatically wraps its children in fences (brackets) with optional separators between them. It has been deprecated in favour of explicit <mo> operators, but you will still meet it in older documents.


Definition and Usage

<mfenced> saved authors from writing opening and closing bracket operators by hand. The open and close attributes set the bracket characters, and separators lists the characters placed between consecutive children.

Attributes

AttributeDescription
openThe opening fence character (default is "(").
closeThe closing fence character (default is ")").
separatorsCharacters placed between children (default is a comma).

Example

This renders an ordered pair inside parentheses. Since <mfenced> is deprecated, the second math block shows the recommended <mo> replacement.

mfenced and its modern equivalent
Example
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>MathML mfenced</title>
</head>
<body>
  <p>Deprecated mfenced:</p>
  <math display="block">
    <mfenced open="(" close=")" separators=",">
      <mi>x</mi>
      <mi>y</mi>
    </mfenced>
  </math>

  <p>Recommended replacement with mo:</p>
  <math display="block">
    <mrow>
      <mo>(</mo>
      <mi>x</mi><mo>,</mo><mi>y</mi>
      <mo>)</mo>
    </mrow>
  </math>
</body>
</html>
⚠️

<mfenced> is deprecated and not part of MathML Core. Prefer explicit <mo> fences (using the stretchy attribute where needed) for reliable rendering in Chrome, Edge, Firefox and Safari.

Key Takeaways

  • <mfenced> auto-wraps children in brackets with separators.
  • open, close and separators control the bracket and delimiter characters.
  • It is deprecated - use <mo>(</mo> and <mo>)</mo> instead.

Related HTML Topics

Keep learning with these closely related tutorials.

Ready to use your HTML skills?

Find web development internships and fresher jobs across India.

Browse Web Dev Internships