HTML5 MathML
HTML5 MathML <mi> Tag
The <mi> element represents an identifier - a variable, a constant name, or a function name. Single-letter identifiers are rendered in italics by default, matching mathematical convention.
Definition and Usage
Use <mi> for anything that names a quantity or function: x, y, sin, log, or a constant like e. A single letter is italicised automatically; multi-letter names such as sin are shown upright. Override the style with mathvariant.
Syntax
Example
<mi>x</mi>
<mi>sin</mi>
<mi mathvariant="bold">v</mi>Attributes
| Attribute | Description |
|---|---|
| mathvariant | Style such as normal, bold, italic, bold-italic, double-struck. |
| mathsize | Font size of the identifier. |
| mathcolor | Text colour of the identifier. |
| mathbackground | Background colour behind the identifier. |
Example
Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>MathML mi</title>
</head>
<body>
<math display="block">
<mrow>
<mi>y</mi><mo>=</mo>
<mi>sin</mi>
<mo>(</mo><mi>x</mi><mo>)</mo>
</mrow>
</math>
</body>
</html>💡
Set mathvariant="normal" on a single-letter identifier that should stay upright, such as the differential d or a unit symbol.
Key Takeaways
- <mi> holds identifiers: variables, constants and function names.
- Single letters are italic by default; multi-letter names are upright.
- mathvariant overrides the automatic styling.
