HTML Tag

The <sup> tag in HTML is used to define superscript text. Superscript text appears half a character's height above the normal line of text and is typically smaller than the surrounding text. It's commonly employed for footnotes, mathematical notations, ordinal numbers, and chemical formulas.

HTML Superscript: The <sup> Tag Explained

Syntax

<sup>text content</sup>

Attributes

Attribute Value Description
This tag does not support any specific attributes.

Example

<p>This is some normal text with <sup>superscript</sup> text.</p>

More Examples

Example 1: Mathematical Equations

Superscript is very useful in mathematical equations to denote exponents:

<p>x<sup>2</sup> + y<sup>2</sup> = z<sup>2</sup></p>
<p>E = mc<sup>2</sup></p>

This will render as:

x2 + y2 = z2

E = mc2

Example 2: Ordinal Numbers

In many languages, ordinal numbers (like 1st, 2nd, 3rd) require the suffix to be superscripted:

<p>The 1<sup>st</sup>, 2<sup>nd</sup>, and 3<sup>rd</sup> place winners are announced.</p>

This will display:

The 1st, 2nd, and 3rd place winners are announced.

Example 3: Footnotes

Often used for footnotes or references in articles or academic texts. Although not ideal for proper footnotes, you can use it for quick inline notes:

<p>This is a sentence with a footnote<sup>1</sup>.</p>
<p><sup>1</sup>This is the footnote content.</p>

This will appear as:

This is a sentence with a footnote1.

1This is the footnote content.

Example 4: Chemical Formulas

In chemical formulas, superscripts are used for ions and isotopes:

<p>SO<sub>4</sub><sup>2-</sup></p>
<p><sup>14</sup>C</p>

This renders as:

SO42-

14C

Browser Support

The <sup> tag is supported by all modern browsers:

  • Chrome
  • Edge
  • Firefox
  • Safari
  • Opera

Notes and Tips

  • Use <sup> for content that genuinely needs to be displayed as superscript. Avoid using it purely for styling purposes.
  • While <sup> is often used for footnotes, consider using semantic HTML elements like <aside> or <figure> with figcaption for more accessible and semantically correct footnotes.
  • For complex mathematical expressions, consider using MathML (<math>) for better rendering and accessibility support. However, using <sup> is fine for basic equations.
  • The styling of superscript can be adjusted with CSS if you need more control over its size, position, or font. For example, you can change the vertical alignment with vertical-align: super; or alter the font size.
  • Combine <sup> with <sub> for specific text formatting.
  • Ensure the superscript text is legible and does not disrupt the readability of your main text.
  • For languages that use ordinal indicators differently, you may have to adjust styling or use other HTML conventions.