Format Code Now
/
Web & markupHTML Superscript Generator Next: HTML Telephone Input Generator ›

HTML Superscript Generator

WM-41

Wrap text in sup or sub, or write a formula with ^{} and _{} markers and let the tool convert it. E = mc^{2} becomes E = mc with a sup element.

Runs in your browser. Nothing is uploaded.

Text (wrap actions) or text with ^{...} and _{...} markers (shorthand action)

HTML

How to use it

  1. For a whole word or number, type it and pick sup or sub.
  2. For a formula, type it with ^{...} for raised and _{...} for lowered parts and pick the shorthand action.
  3. Copy the markup.
  4. Paste it into your page.

When sup and sub are the right tool

sup is for text that is raised for meaning: exponents, ordinal indicators such as the th in 4th in some languages, and footnote marks. sub is for lowered text, most often chemical formulas such as H2O and CO2, and mathematical indices. The standard says they should be used where the position changes the meaning, not just for looks. Browsers raise or lower the text and reduce its size by default.

How the shorthand works

The shorthand action finds each ^{...} and _{...} in the text, turns it into sup or sub around what is inside the braces, and escapes everything else. The braces cannot be nested and cannot hold a line break. If no marker is found, the tool says so instead of returning your text unchanged. The tool does not guess where an exponent goes, so write the markers where you want them.

Error messages and what to do

MessageWhat it meansFix
No ^{...} or _{...} markers found. Write x^{2} for a superscript or H_{2}O for a subscript.The shorthand action found nothing to convert.Add markers where the raised or lowered text goes.

Questions people ask

How do I write superscript in HTML?

Put the text between sup tags, for example x with a sup element holding 2. Use sub for subscript. The element raises the text and shrinks it a little by default, and you can restyle it with CSS if you wish.

How do I write H2O in HTML?

Write H, then a sub element containing 2, then O. With the shorthand action you can type H_{2}O and get exactly that. The same approach works for CO2 and other formulas, and it keeps the digit as normal text that screen readers can read.

Can I use sup for footnote numbers?

Yes, that is a common use. Link the number to the footnote so keyboard and screen reader users can reach it. Keep the number short, and give the link text a clear name or an aria-label so it is not read as a bare digit.

Is sup the same as the superscript CSS?

No. The element carries meaning and also raises the text. The CSS property vertical-align: super only changes position, and does not tell anything that reads the page what the text is.

Do I need entity codes for superscript digits?

No. Unicode has superscript characters for some digits, but they do not cover every character and screen readers handle them inconsistently. sup works with any text.

About this tool

The sup and sub actions wrap everything you typed in one element. The shorthand action leaves your text alone and turns ^{2} into <sup>2</sup> and _{2} into <sub>2</sub>, so a whole formula is written in one pass. The braces cannot nest and cannot hold a line break, and any other text is only escaped. If no marker is found, it says so instead of returning your text unchanged. sup and sub are for text whose meaning needs the raised or lowered position, such as exponents, footnote marks and chemical formulas. They are not for styling; for purely visual shifts use CSS. Optional lines: id:, class:, title:, lang:, data-* and aria-*.

Format Code Now: free, no ads, no accounts. Your input stays in your browser.