How to Add Subscript and Superscript in Markdown
Markdown has no native subscript or superscript. Learn the workarounds — HTML tags, Unicode, and math extensions — with copy-paste examples.
Subscript and superscript text shows up in chemistry (H₂O, CO₂), math (x², aⁿ), footnotes (word¹), trademarks (™), and ISO dates. Yet, despite how common these are, neither subscript nor superscript is part of the original Markdown specification or of GitHub Flavored Markdown. To display them you have to reach for one of three workarounds: inline HTML tags, Unicode characters, or a math extension. This reference walks through each method, shows you when to use which, and highlights the gotchas that catch people in practice.
Does Standard Markdown Support Subscript and Superscript?
No. Neither John Gruber's original Markdown syntax nor CommonMark defines a way to write subscript or superscript text. The caret (^) and tilde (~) characters have no special meaning in those specs, so writing x^2 or H~2~O renders as literal text.
Some Markdown flavors do add extensions:
- Pandoc Markdown and R Markdown use tildes for subscript (
H~2~O) and carets for superscript (x^2^). These are the most widely supported extensions in technical writing. - PHP Markdown Extra and some others use similar conventions.
- GitHub Flavored Markdown (GFM) does not support either — but it does render inline HTML and KaTeX/MathJax, which gives you two indirect paths.
Because GFM is what most modern editors, docs sites, and converters render by default, the realistic options for most writers are inline HTML or Unicode characters. The table below summarizes the trade-offs:
| Method | Spec coverage | Renders in GFM | Renders in PDF/Word export | Best for |
|---|---|---|---|---|
| Inline HTML tags | CommonMark, GFM | Yes | Usually yes | Any document, full control |
| Unicode characters | Plain text (universal) | Yes | Always (it is just text) | One-off symbols, copy-paste |
Pandoc ~sub~ / ^super^ | Pandoc, R Markdown | No | Yes, via Pandoc | Academic and scientific docs |
LaTeX math $x^2$ | MathJax/KaTeX-enabled renderers | Sometimes | Sometimes | Formulas with variables |
If you are not sure which renderer will consume your Markdown, HTML and Unicode are the safest choices.
Add Subscript in Markdown with HTML Tags
Because Markdown passes inline HTML through untouched, the standard <sub> tag is the most reliable way to write subscript text. Wrap the characters that should sit below the baseline:
The chemical formula for water is H<sub>2</sub>O,
and carbon dioxide is CO<sub>2</sub>.
Rendered, that gives you H2O and CO2 — exactly what you want in chemistry notes or a science report.
Tips for Using the <sub> Tag Reliably
- Keep tags inline, not block. Place
<sub>inside a paragraph rather than on its own line. - Do not nest. A subscript inside another subscript is rarely meaningful and confuses renderers.
- Watch your export target. When converting to Word, a good translator maps
<sub>to Word's native subscript formatting. When converting to PDF, the layout engine handles it natively. - Escape literal angle brackets. If you want to show the tag itself in documentation, wrap it in backticks like
`H<sub>2</sub>O`so the renderer does not interpret it.
A quick checklist:
- Tag wraps only the characters that should be subscript
- Lowercase tag name (
<sub>, not<SUB>) - Closing tag present (
</sub>) - No spaces between the tag and the characters
Write Superscript in Markdown for Exponents and Footnotes
Superscript works just like subscript, but with <sup> instead. The most common uses are exponents in math and reference markers for footnotes:
Einstein's famous equation is E = mc<sup>2</sup>,
and the area of a circle is A = πr<sup>2</sup>.
Rendered, you get E = mc2 and A = πr2. The same approach handles footnote markers:
The results were statistically significant.<sup>1</sup>
Further analysis is pending.<sup>2</sup>
Tip: if your document has more than a handful of footnotes, consider a renderer that supports the Pandoc footnote extension (
[^1]) instead. It produces real, clickable footnotes rather than visual superscripts, and most academic PDF workflows handle it natively.
Common Superscript Pitfalls
- Trademark symbols. For ™, ®, and © you do not need a tag at all — those glyphs exist as plain Unicode characters (see the next section).
- Ordinal numbers. "1st", "2nd", "3rd" usually look fine as plain text. Reaching for
<sup>everywhere makes the source noisy. Mixing methodswithin one document. Pick HTML or Unicode and stick with it; mixing creates inconsistent baselines.- Strikethrough confusion. GFM uses
~~text~~for strikethrough, which is unrelated to subscript despite the shared tilde character.
Use Unicode for Subscript and Superscript in Markdown
Unicode defines ready-made subscript and superscript characters for many common letters and digits. Because they are plain text, they render everywhere — in any Markdown editor, any converter, any terminal — without tags or extensions.
Unicode Superscript Characters
| Plain | Superscript | Unicode name |
|---|---|---|
| 0 | ⁰ | Superscript zero |
| 1 | ¹ | Superscript one |
| 2 | ² | Superscript two |
| 3 | ³ | Superscript three |
| 4–9 | ⁴⁵⁶⁷⁸⁹ | Superscript four–nine |
| n | ⁿ | Superscript latin small n |
| i | ⁱ | Superscript latin small i |
So you can write E = mc² directly, with no markup at all. This is the approach most technical writers use for one-off exponents in mixed-format documents.
Unicode Subscript Characters
| Plain | Subscript | Unicode name |
|---|---|---|
| 0–9 | ₀₁₂₃₄₅₆₇₈₉ | Subscript zero–nine |
| a, e, o | ₐ ₑ ₒ | Subscript latin letters |
| x | ₓ | Subscript latin small x |
This lets you write H₂O, CO₂, and CH₄ as plain text. The big limitation is coverage: Unicode has no subscript for uppercase letters and very few lowercase letters, so chemical formulas like C₆H₁₂O₆ work but something like NaCl-style labels do not. For full coverage, fall back to the <sub> tag.
When to Use Which
- Use Unicode for digits, common math symbols, and the handful of supported letters. It is plain text, so it survives every conversion path including Markdown to PDF and Markdown to Word.
- Use HTML tags when you need full alphabet coverage or consistent rendering across all renderers.
- Use a math extension only when your document is already heavy on equations and your renderer supports KaTeX/MathJax.
A useful Pandoc-style fallback (works in Pandoc, R Markdown, Quarto, and some others) uses tildes and carets as shorthand:
The mass ratio is H~2~O to x^2^ under standard conditions.
Treat this as a convenience feature, not a portable one — it renders as plain text in stock GFM, which is why the HTML and Unicode approaches above remain the most reliable for general writing.
Conclusion: Choose a Subscript and Superscript Method in Markdown
Because Markdown itself has no subscript or superscript syntax, your choice is really about portability versus coverage. For maximum compatibility, use the <sub> and <sup> HTML tags — they render in every GFM-aware tool and translate cleanly into Word's native subscript and superscript styles when you convert Markdown to Word. For quick, one-off symbols, Unicode characters (H₂O, x²) are unbeatable because they are just text. Reserve Pandoc's ~sub~ / ^super^ shorthand or LaTeX math for documents you know will be processed by Pandoc or a math-aware renderer. Whichever path you pick, keep it consistent within a document and preview before you export to PDF or HTML. Browse the blog for more Markdown formatting references.