Definition and Usage
The sup tag represents superscript inline text.
Usage Notes
- In most browsers, text within the
<sup>tag is rendered smaller and positioned above the baseline by default. - The
<sup>tag is not intended solely for visual styling or decorative purposes. - It should be used to represent exponents, ordinal numbers, or other content that is conventionally displayed as superscript according to typographical rules or conventions.
- Use this tag only when it clarifies that the content carries such semantic meaning.
Usage Examples
The <sup> tag should be used to convey semantic meaning such as exponents or ordinal numbers according to typographical rules or conventions.
Using as an Exponent
<var>E</var>=<var>m</var><var>c</var><sup>2</sup>
Code Explanation
The <var> tag represents a variable.
It is used to indicate mathematical expressions, actual variables, or physical quantities.
<p>Example showing x squared: <var>x</var><sup>2</sup></p>
Example showing x squared: x2
Using for Ordinal Numbers
5<sup>th</sup>
Note:
The <sup> tag is not limited to representing only exponents or ordinal numbers as shown in the examples. It can be used for any superscript content according to typographical rules or conventions.
Registered Trademark<sup>©</sup>
Precautions
The <sup> tag should be used to convey semantic meaning such as exponents or ordinal numbers according to typographical rules or conventions. It is not intended solely for visual styling or decorative purposes, and should only be used when it clarifies such meaning in the content.
Let's revisit the "Einstein's theory of relativity" example. Without the <sup> tag, the intended meaning would change.
<var>E</var>=<var>m</var><var>c</var><sup>2</sup>
Now, let's see the same example without the <sup> tag:
<var>E</var>=<var>m</var><var>c</var>2
In this case, the 2 that represents the squared exponent is interpreted as a plain number multiplied by 2. One might argue this is just a styling issue, but considering web accessibility and screen readers, it is more than just a visual problem — the semantic meaning is actually lost.
The following example shows using a <span> styled with CSS to visually mimic superscript without using the <sup> tag:
<var>E</var>=<var>m</var><var>c</var><span style="vertical-align: super; font-size: 0.75em;">2</span>
Do not use CSS styling to replace the <sup> tag solely for visual purposes. Even if it looks correct, the semantic meaning is altered.
Next, let's examine the "fifth in English ordinal" example:
5<sup>th</sup>
Now, let's mark it up without the <sup> tag:
5th
As you can see, leaving out the <sup> tag does not break the syntax; it is not invalid HTML.
However, HTML provides tags with semantic meaning. It is recommended to use the most appropriate tag for the content.
Typographically or by convention, ordinal indicators should use the <sup> tag. Using <sup> ensures that the th is clearly recognized as an ordinal indicator, which aligns better with web standards and semantic HTML.
Browser compatibility
| Tag |
Desktop Chrome
|
DesktopDesktop Edge
|
Desktop Firefox
|
Safari
|
|---|---|---|---|---|
<sup>
|
1 | 12 | 1 | 4 |
Specifications
| Specification | |
|---|---|
<sup>
|
HTML Standard #the-sub-and-sup-elements |