<msup>
Write a mathematical superscript or subscript
<msup> + <msub> — Superscript and subscript
<msup> displays a superscript (x squared, power n). <msub> displays a subscript (x subscript 1, a subscript n). These are mathematical constructs, different from <sup> and <sub> which are typographic.
When to use it
You want to write a power, a sequence index, a subscript coefficient, or scientific notation in a formula. <msup> takes two children: the base and the exponent. <msub> takes two children: the base and the subscript. Do not confuse them with HTML's <sup> and <sub>, which are used for abbreviations and typography.
What you gain
Accessibility: screen readers announce "x squared" or "a subscript n" instead of reading the characters individually. The mathematical structure is preserved.
Code example
<math display="block">
<mrow>
<msup>
<mi>x</mi>
<mn>2</mn>
</msup>
<mo>+</mo>
<msub>
<mi>a</mi>
<mi>n</mi>
</msub>
<mo>=</mo>
<mn>0</mn>
</mrow>
</math>