HTML5 MathML
HTML5 MathML <mglyph> Tag
The <mglyph> element displays a symbol that is not available as a normal text character - typically an image or a font glyph referenced by other means. It fills gaps where a required mathematical symbol has no Unicode code point in the current font.
Definition and Usage
<mglyph> is an empty (self-contained) element. Historically it referenced an image with src, or a specific glyph via a font. Use it only when no standard character or entity will do, since custom glyphs reduce accessibility and portability.
Attributes
| Attribute | Description |
|---|---|
| src | URL of an image to display as the glyph. |
| width | Rendered width of the glyph. |
| height | Rendered height of the glyph. |
| alt | Alternative text describing the glyph. |
Example
This uses <mglyph> with an image as a decorative symbol in an expression. If the image fails to load, the alt text is shown.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>MathML mglyph</title>
</head>
<body>
<math display="block">
<mrow>
<mi>f</mi>
<mo>=</mo>
<mglyph src="star.png" width="16px" height="16px" alt="star symbol"></mglyph>
<mo>+</mo>
<mn>1</mn>
</mrow>
</math>
</body>
</html><mglyph> is rarely needed today and has patchy support in MathML Core. Prefer Unicode characters or named entities (like α) whenever possible for accessibility.
Key Takeaways
- <mglyph> shows a glyph or image not available as a standard character.
- src points to an image; always supply alt text.
- Use standard Unicode symbols first - reserve <mglyph> for genuine gaps.
