zaro

What displays text in superscript form?

Published in HTML Text Formatting 2 mins read

The <sup> (superscript) HTML tag is primarily used to display text in superscript form on web pages, positioning content slightly above the normal line.

Understanding Superscript Text on the Web

Superscript text is a typographical convention where characters are set slightly above the normal line of type. It often appears in a smaller font size compared to the surrounding text. On the web, its utility is widespread, including:

  • Footnotes: For referencing sources or adding supplementary information, similar to the "WWW" example.
  • Mathematical Expressions: Indicating exponents or powers (e.g., 2³).
  • Ordinal Indicators: Denoting sequence (e.g., 1ˢᵗ, 2ⁿᵈ).
  • Copyright or Trademark Symbols: Although dedicated symbols exist, superscript can sometimes be used.

The HTML <sup> Tag

The <sup> tag specifically defines text as superscript within web documents. It's a semantic tag, meaning it conveys meaning about the text's role (e.g., being an exponent or a footnote reference) rather than just its visual presentation.

Key characteristics of text defined by the <sup> tag include:

  • Positioning: Text enclosed within <sup> tags appears approximately half a character above the standard baseline of the text.
  • Font Rendering: Browsers commonly render superscript text in a slightly smaller font size, enhancing its visual distinction from the main text.
  • Purpose: It is ideal for small print, legal disclaimers, mathematical powers (e.g., E=mc²), ordinal numbers (e.g., 1ˢᵗ), and most notably, for footnotes like WWW.

Practical Usage Example

To apply superscript formatting in HTML, you simply wrap the desired text within the <sup> and </sup> tags:

<p>
  This is a paragraph with a footnote.<sup style="font-size: 0.75em;">1</sup>
</p>

<p>
  In mathematics, 2<sup>3</sup> equals 8.
</p>

<p>
  We are celebrating our 10<sup>th</sup> anniversary.
</p>

Contrasting with Subscript Text (<sub>)

The <sub> (subscript) tag is the counterpart to <sup>, used for displaying text that appears below the normal line. While <sup> raises text, <sub> lowers it.

The <sub> tag defines text that appears half a character below the normal line. It is commonly used for:

  • Chemical Formulas: Such as H₂O (water) or CO₂ (carbon dioxide).
  • Mathematical Indices: Denoting elements in a sequence (e.g., aᵢ).

Superscript vs. Subscript Comparison

Feature <sup> (Superscript) <sub> (Subscript)
HTML Tag <sup> <sub>
Vertical Position Half a character above the normal line Half a character below the normal line
Font Rendering Often smaller Often smaller
Primary Uses Footnotes (e.g., WWW¹), exponents (x²), ordinal numbers (1ˢᵗ) Chemical formulas (H₂O), mathematical indices (aᵢ)