HTML5 MathML
HTML5 MathML id Attribute
The id attribute assigns a unique identifier to a MathML element. Like in HTML, it is used for CSS styling, JavaScript access and internal linking.
Definition and usage
The id attribute is a global attribute available on every MathML element. Its value must be unique within the document. You can target the element with a CSS #id selector, retrieve it with document.getElementById, or reference it from another element.
Which elements use it
- Every MathML element accepts id, as it is a global attribute.
Example
<math>
<mfrac id="halfFraction">
<mn>1</mn>
<mn>2</mn>
</mfrac>
</math>The fraction now has the id halfFraction, so CSS like #halfFraction { color: blue; } or scripting can target it directly.
ℹ️
As a global attribute, id is part of MathML Core and supported by all modern browsers.
