<sub> & <sup> Tags in HTML

Quick facts

CategoryFlow content, phrasing content, palpable content
Content modelPhrasing content
Tag omissionNeither the start nor the end tag can be omitted
Permitted parentsAny element that accepts phrasing content
DOM interfaceHTMLElement (both)

Syntax

<p>Water is H<sub>2</sub>O.</p> <p>E = mc<sup>2</sup></p>

Live example

Edit the code below and watch the preview update instantly.

index.html
Preview

Attributes

AttributeDescription
—Both accept only the global attributes.

Common examples

Chemical formulas

Subscript numbers are part of the formula’s meaning.

<p>Water is H<sub>2</sub>O and carbon dioxide is CO<sub>2</sub>.</p>

Exponents and units

Superscript for powers and square or cubic units.

<p>E = mc<sup>2</sup>. The room is 20 m<sup>2</sup>.</p>

Footnote references

A superscript number that links to the note at the bottom of the page.

<p>HTML was invented in 1991.<sup><a href="#note1" id="ref1">1</a></sup></p> … <p id="note1">1. Tim Berners-Lee, CERN. <a href="#ref1">↩</a></p>

Ordinal numbers in French or English

Some languages require superscript in abbreviations, such as French “1er“.

<p>Le 1<sup>er</sup> janvier · the 21<sup>st</sup> century</p>

<sup> vs CSS vertical-align

<sup> and <sub> are for cases where the raised or lowered position is part of the meaning — “m2” isn’t the same as “m2”. CSS vertical-align: super only changes how text looks.

Use the elements for formulas, exponents, footnotes and language rules. Use CSS when the position is purely a design choice, such as a small raised “NEW” label on a menu item.

<sup> / <sub>vertical-align
MeaningYesNo (visual only)
Copy & paste keeps itUsuallyNo
Best forMath, chemistry, footnotesDecorative labels

Common mistakes to avoid

  • Using them just to make text small. Use <small> or CSS font-size.
  • Footnote numbers that aren’t links. Link the number to the note and back, so readers can jump between them.
  • Building complex math with nested sup and sub. It quickly becomes unreadable; use MathML.
  • Ignoring line-height. Raised text can push lines apart; fix it with CSS (see the FAQ below).

Accessibility & SEO tips

  • Screen readers usually don’t announce superscript or subscript, so “m2” may be read for “m²” — for important units, consider the ² character or add the words “square metres”.
  • Unicode characters such as ², ³ and ™ are handy for common cases and keep the meaning when copied.
  • Footnote links should have enough space around them to tap on a phone.
  • For scientific or mathematical content, check the page with a screen reader once — if formulas don’t read sensibly, add a short text explanation beside them.

Browser support

Supported in every browser, including Chrome, Edge, Firefox, Safari and their mobile versions — it has been part of HTML since the very first versions.

Related tags

Frequently asked questions

Why does <sup> or <sub> change the spacing between my lines?
The raised or lowered text pushes the line height. Add sub, sup { line-height: 0; } to your CSS to keep the line spacing even.
Should I use <sup> for a trademark symbol?
You can, but the ™ and ® characters already sit raised in most fonts, so they usually don't need <sup>. Use <sup> when a font displays them at full size and you want them smaller and raised.
How do I write complex math formulas?
<sub> and <sup> are fine for simple formulas. For fractions, roots and matrices, use MathML (the <math> element), which modern browsers support.
How do I write "x squared" in HTML?
Write x<sup>2</sup>, or use the ready-made character ² (&sup2;). Both display as x².
How do I make footnotes in HTML?
Put a superscript link such as <sup><a href="#n1">1</a></sup> in the text and a matching element with id="n1" at the bottom, with a link back.
Can I use <sub> and <sup> together?
Yes, for example for isotopes or indexes, but complex notation is clearer in MathML.
How do I write a trademark or registered symbol?
Use the ready-made characters ™ (&trade;) and ® (&reg;). They're already raised, so you don't need <sup>, though some designs wrap ® in <sup> to make it smaller.
How do I make <sup> smaller?
Use CSS, for example sup { font-size: 0.7em; }. Pair it with line-height: 0 so it doesn't push the lines apart.
Does <sub> work inside links and headings?
Yes. Both are inline elements, so they work anywhere text can go, including links, headings, buttons and table cells.