MyInternships.in

HTML5 MathML

HTML5 MathML Attribute Complete Reference

This reference lists the MathML attributes you can apply to elements inside the HTML5 <math> root. The table gives each attribute, the elements it applies to, and what it does, followed by a runnable example.


MathML Attribute Reference

AttributeApplies toDescription
display<math>block or inline rendering.
dir<math>Text direction ltr or rtl.
mathcolormost elementsForeground (text) colour.
mathbackgroundmost elementsBackground colour.
mathsizetoken elementsFont size of the content.
mathvariant<mi>, <mn>, <mo>Font style such as bold or double-struck.
idall elementsUnique identifier for CSS/scripting.
classall elementsCSS class name(s).
styleall elementsInline CSS declarations.
linethickness<mfrac>Thickness of the fraction bar.
bevelled<mfrac>Diagonal fraction when true.
numalign<mfrac>Numerator alignment.
denomalign<mfrac>Denominator alignment.
stretchy<mo>Whether the operator stretches.
largeop<mo>Render as a large operator.
movablelimits<mo>Allow limits to move under/over.
separator<mo>Mark the operator as a separator.
fence<mo>Mark the operator as a fence.
lspace<mo>, <mpadded>Space added to the left.
rspace<mo>Space added to the right.
accent<mover>, <munder>Draw the script as a tight accent.
accentunder<munderover>Accent for the underscript.
notation<menclose>Enclosure kind such as box or circle.
actiontype<maction>Interactive action to perform.
selection<maction>Which child is currently shown.
open<mfenced>Opening bracket character.
close<mfenced>Closing bracket character.
separators<mfenced>Characters placed between children.
width<mpadded>, <mspace>Width of the box or space.
height<mpadded>, <mspace>Height above the baseline.
depth<mpadded>, <mspace>Depth below the baseline.
voffset<mpadded>Vertical shift of the content.
frame<mtable>Outer border of a table.
rowalign<mtable>, <mtr>Vertical alignment of row cells.
columnalign<mtable>, <mtr>, <mtd>Horizontal alignment of columns.
rowlines<mtable>Interior horizontal separators.
columnlines<mtable>Interior vertical separators.
align<mtable>Vertical alignment of the whole table.
scriptsizemultiplier<mstyle>Shrink factor per script level.
scriptlevel<mstyle>Base script (font-size) level.
src<mglyph>Image URL for a custom glyph.

Example

This example applies several attributes at once: display on <math>, mathcolor on an identifier, and linethickness on a fraction.

Multiple attributes together
Example
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>MathML Attribute Reference Example</title>
</head>
<body>
  <math display="block">
    <mrow>
      <mi mathcolor="teal">P</mi>
      <mo>=</mo>
      <mfrac linethickness="2px">
        <mi>W</mi>
        <mi>t</mi>
      </mfrac>
    </mrow>
  </math>
</body>
</html>
ℹ️

Many presentation attributes have CSS equivalents (color, background, font-size) that work in MathML Core. A few attributes belong to legacy elements (mfenced, maction) with weaker support.

Key Takeaways

  • Global attributes (id, class, style, mathcolor) apply broadly; others are element-specific.
  • Table attributes (frame, rowalign, columnalign) shape matrices and systems.
  • CSS is a reliable modern alternative to many presentation attributes.

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