Standard CommonMark and GitHub Flavored Markdown do not have universal subscript or superscript punctuation. On GitHub, use inline HTML: H<sub>2</sub>O and x<sup>2</sup>. Pandoc and MultiMarkdown also support H~2~O and x^2^. Unicode characters such as H₂O and x² are the most portable when the required characters exist.
Markdown subscript and superscript syntax reference
| Goal | Syntax | Renders as |
|---|---|---|
| Subscript (shorthand) | H~2~O |
H with a lowered 2 |
| Superscript (shorthand) | x^2^ |
x with a raised 2 |
| Portable subscript (HTML) | H<sub>2</sub>O |
H with a lowered 2 |
| Portable superscript (HTML) | x<sup>2</sup> |
x with a raised 2 |
| Unicode subscript | H₂O (paste ₂) |
H with a lowered 2 |
| Unicode superscript | x² (paste ²) |
x with a raised 2 |
Markdown subscript and superscript key facts
- There are three ways to write raised or lowered text in Markdown: the
~and^shorthand, the<sub>and<sup>HTML tags, and Unicode characters like ² and ₂. - The
~sub~and^super^shorthand works only in Pandoc and MultiMarkdown. It does not work in CommonMark, GitHub Flavored Markdown, or Markdown Extra. - The
<sub>and<sup>HTML tags are the most portable option and work anywhere inline HTML is allowed, including GitHub. - Unicode characters such as ² and ₂ need no markup at all, so they render even in plain text and chat apps, but Unicode only covers the digits, a few signs, and a limited set of letters.
- A single tilde means subscript in Pandoc and MultiMarkdown, while a double tilde means strikethrough in GitHub Flavored Markdown.
- For real mathematical notation, LaTeX math is clearer and more accessible than stacked superscripts.
Pick a portable fallback before publishing
Subscript and superscript markers are extensions. Pandoc, MultiMarkdown, and some editors support tilde or caret syntax, but CommonMark and GFM do not define it consistently. The same characters can also be used for strikethrough, escaping, or ordinary punctuation.
For a controlled website, <sub> and <sup> are clearer fallbacks when trusted inline HTML is allowed. For mathematical expressions, use the destination's LaTeX math support instead of mixing text-level superscript conventions. Always preview chemical formulas, units, exponents, and footnote-like markers in the target renderer.
Basic syntax
In Pandoc and MultiMarkdown, wrap the lowered text in single tilde characters and the raised text in single caret characters.
Markdown
Water is H~2~O and 2^10^ is 1024.
Rendered output (in a supporting flavor such as Pandoc)
Water is H2O and 210 is 1024.
HTML output
<p>Water is H<sub>2</sub>O and 2<sup>10</sup> is 1024.</p>
Note that a single tilde marks subscript, while two tildes (~~text~~) mean strikethrough in flavors that support it. This overlap is a common source of confusion, covered below.
No spaces inside the markers
The text between the markers cannot contain an unescaped space or a newline. If it does, the parser treats the tildes or carets as literal characters and does not apply the formatting.
Markdown
This works: O~2~
This does not: O~two words~
Rendered output
This works: O2 This does not: O~two words~
To include a space, escape it with a backslash so the run stays intact.
Markdown
P~a\ cat~
Rendered output
Pa cat
Superscript for footnote-style marks and math
Superscript is useful for exponents, ordinals, and inline references.
Markdown
The area of a circle is πr^2^, and the 1^st^ result matters most.
Rendered output
The area of a circle is πr2, and the 1st result matters most.
HTML output
<p>The area of a circle is πr<sup>2</sup>, and the 1<sup>st</sup> result matters most.</p>
For heavy mathematical notation, prefer LaTeX math rather than superscript markup, since LaTeX handles complex expressions cleanly. See LaTeX math in Markdown.
The portable HTML fallback
Because the tilde and caret syntax is not universal, the reliable cross-platform approach is the HTML <sub> and <sup> tags. Almost every renderer that allows inline HTML, which is most of them, handles these correctly, including GitHub.
Markdown
Water is H<sub>2</sub>O and x<sup>2</sup> is x squared.
Rendered output
Water is H2O and x2 is x squared.
HTML output
<p>Water is H<sub>2</sub>O and x<sup>2</sup> is x squared.</p>
Use this form whenever the document might be read on GitHub or on a plain CommonMark renderer, where the ~ and ^ shorthand does not work.
Unicode subscript and superscript characters
Unicode includes ready-made raised and lowered characters. Because they are ordinary characters, not markup, they display everywhere with no Markdown or HTML support required, including in plain text, file names, and chat apps that render no formatting at all. You type or paste the character directly.
Markdown
Water is H₂O, carbon dioxide is CO₂, and c² appears in E = mc².
Rendered output
Water is H₂O, carbon dioxide is CO₂, and c² appears in E = mc².
Digits and a few signs have complete coverage in both forms:
| Set | Characters |
|---|---|
| Superscript digits | ⁰ ¹ ² ³ ⁴ ⁵ ⁶ ⁷ ⁸ ⁹ |
| Subscript digits | ₀ ₁ ₂ ₃ ₄ ₅ ₆ ₇ ₈ ₉ |
| Superscript signs | ⁺ ⁻ ⁼ ⁽ ⁾ |
| Subscript signs | ₊ ₋ ₌ ₍ ₎ |
Letter coverage is incomplete, which is the main limitation. Unicode has no subscript b, c, d, f, g, q, w, y, or z, and no superscript q or capital C, F, Q, S, X, Y, or Z. If a letter has no Unicode form, you cannot build the word this way, so fall back to the <sub> or <sup> tags. Unicode is best for short numeric runs such as chemical formulas, exponents, and units.
Choosing a method
| Method | Syntax | Where it works | Best for |
|---|---|---|---|
| Shorthand | ~x~ and ^x^ |
Pandoc and MultiMarkdown only | Documents you convert with Pandoc or MultiMarkdown |
| HTML tags | <sub>x</sub> and <sup>x</sup> |
Anywhere inline HTML is allowed, including GitHub | Portable, meaningful content such as formulas and math |
| Unicode characters | ², ₂ typed directly |
Everywhere, even plain text | Short digit runs, units, and chat or plain-text contexts |
As a rule: use the HTML tags for portable, meaningful content; reach for Unicode when you want zero markup or need it to survive in plain text; and use the ~/^ shorthand only in a Pandoc or MultiMarkdown pipeline.
Common use cases
| Use case | Example | How to write it |
|---|---|---|
| Chemical formulas | H₂O, CO₂, C₆H₁₂O₆ | H<sub>2</sub>O or Unicode ₂ |
| Exponents and powers | x², E = mc², 10⁻⁹ | x<sup>2</sup> or Unicode ² |
| Ordinals | 1ˢᵗ, 2ⁿᵈ, 3ʳᵈ | 1<sup>st</sup> or Unicode |
| Units | m², cm³, km² | Unicode ² and ³ |
| Isotopes | ¹⁴C, ²³⁵U | <sup>14</sup>C or Unicode |
| Footnote and reference marks | See note² | note<sup>2</sup> |
The tilde collision with strikethrough
A single tilde is subscript in Pandoc and MultiMarkdown, but a double tilde is strikethrough in GFM. On GitHub, writing H~2~O does not produce a subscript. GitHub reads the tildes as strikethrough markers and can render the text with a line through it or leave the tildes literal. This is a key reason to use <sub> and <sup> on GitHub. See Strikethrough in Markdown.
Flavor differences
The ~ and ^ shorthand is Pandoc and MultiMarkdown territory. CommonMark and GFM do not support it, and classic Markdown Extra does not define it. The portable answer everywhere is the HTML fallback.
| Flavor | ~sub~ and ^super^ shorthand |
Notes |
|---|---|---|
| CommonMark | No | Not in the spec. <sub> and <sup> HTML work if inline HTML is allowed. |
| GitHub Flavored Markdown (GFM) | No | The shorthand does not render. A single tilde collides with strikethrough. Use <sub> and <sup> HTML, which GitHub supports. |
| MultiMarkdown | Yes | Supports H~2~O and x^2^ as documented in the MultiMarkdown user's guide. |
| Markdown Extra | No | The michelf Markdown Extra specification does not define subscript or superscript. |
| Pandoc | Yes | The superscript and subscript extensions are enabled by default in pandoc's Markdown. |
The practical rule: if you know the document is processed by Pandoc or MultiMarkdown, the ~ and ^ shorthand is fine. Everywhere else, and for portable content, use the HTML tags.
Other platforms (Reddit, Obsidian)
Chat and note tools handle raised and lowered text differently, and the shorthand is not consistent:
- Reddit: supports superscript with a single leading caret and no closing caret, as in
^text, which raises the run until the next space. Wrap multiple words in parentheses,^(multi word). Reddit does not support subscript. - Obsidian: does not render the
~and^shorthand by default. Use the<sub>and<sup>HTML tags, which Obsidian accepts, or a community plugin.
For the full comparison of how flavors differ across all elements, see Markdown flavors.
How Markdific renders it
Markdific renders text and standard Markdown elements. The <sub> and <sup> HTML tags are the portable way to show subscript and superscript where inline HTML is supported. The ~sub~ and ^super^ shorthand from Pandoc and MultiMarkdown is non-standard and may appear as literal text unless the renderer supports it.
For raised and lowered text that renders consistently, the <sub> and <sup> HTML tags are the safest choice. Try it in the Markdific online editor.
Accessibility and SEO notes
The method you choose affects how the text is read by assistive technology and indexed by search engines, so it is worth matching the method to the purpose.
- Prefer
<sub>and<sup>for meaningful content. They are semantic HTML, so the text stays real, selectable, indexable text, and assistive technology can convey the relationship. This is the right choice for chemical formulas, math, and anything a reader might search for or copy. - Use Unicode characters with care. They are convenient and fully portable, but each is a distinct code point, so a search for "H2O" will not match "H₂O", and screen readers may announce them inconsistently. Reserve Unicode for casual or plain-text contexts rather than content that must be searchable or fully accessible.
- Use LaTeX math for real equations. For anything beyond a simple exponent, a math renderer such as MathJax or KaTeX produces cleaner, more accessible output than stacked superscripts. See LaTeX math in Markdown.
Common mistakes and gotchas
- Expecting the shorthand on GitHub.
H~2~Odoes not subscript on GitHub. UseH<sub>2</sub>O. - Single vs double tilde. One tilde is subscript in Pandoc and MultiMarkdown; two tildes are strikethrough in GFM. Mixing them up changes the meaning.
- Spaces inside the markers. An unescaped space breaks the run and leaves the tildes or carets as literal characters. Escape spaces with a backslash.
- Assuming portability. The shorthand works only in Pandoc and MultiMarkdown. For anything cross-platform, use the HTML tags.
- Overusing superscript for math. Complex expressions read better as LaTeX math than as stacked superscripts.
- Forgetting the closing marker. In Pandoc and MultiMarkdown both the opening and closing marker are required. A single unmatched
^or~renders literally.
Best practices
- For portable documents, use
<sub>and<sup>HTML tags rather than the~and^shorthand. - Reserve the shorthand for pipelines you control that run Pandoc or MultiMarkdown.
- Never put unescaped spaces between the markers.
- On GitHub, always use the HTML tags, since the shorthand does not work and a single tilde can trigger strikethrough behavior.
- For real mathematical notation, use LaTeX math instead of superscript markup.
- Keep raised and lowered text short, such as digits or a couple of letters, for readability.
HTML equivalent
Both the shorthand and the HTML fallback compile to the same standard HTML elements: <sub> for subscript and <sup> for superscript.
Markdown
H~2~O and E = mc^2^
HTML output
<p>H<sub>2</sub>O and E = mc<sup>2</sup></p>
FAQ
How do you write subscript and superscript in Markdown?
In Pandoc and MultiMarkdown, wrap text in single tildes for subscript (H~2~O) and single carets for superscript (x^2^). Elsewhere, use the <sub> and <sup> HTML tags.
Does GitHub support subscript and superscript?
Not with the ~ and ^ shorthand. GitHub does support the <sub> and <sup> HTML tags, so use H<sub>2</sub>O and x<sup>2</sup> in GitHub Markdown.
Why does H~2~O not render as subscript?
Because your renderer does not support the shorthand. On GitHub in particular a single tilde is read as part of strikethrough, not as subscript. Use the HTML tags instead.
Is subscript and superscript part of CommonMark?
No. Neither CommonMark nor GitHub Flavored Markdown defines the ~ and ^ shorthand. It comes from Pandoc and MultiMarkdown.
What is the most portable way to add subscript or superscript?
The HTML <sub> and <sup> tags. Nearly every renderer that allows inline HTML supports them, including GitHub and plain CommonMark tools.
Can the subscript or superscript text contain spaces?
Not directly. An unescaped space breaks the run. In Pandoc, escape the space with a backslash, for example P~a\ cat~, to keep the text together.
What is the difference between one tilde and two tildes? One tilde marks subscript in Pandoc and MultiMarkdown. Two tildes mark strikethrough in GitHub Flavored Markdown. They are different features that happen to share the tilde character.
Should I use superscript for math equations? For simple exponents it is fine. For complex expressions, LaTeX math is clearer and better supported by math-aware renderers.
How do you write subscript or superscript with Unicode characters?
Type or paste the ready-made character, such as ² for squared or ₂ for a lowered 2, so x² and H₂O need no markup. Unicode covers all digits and a few signs, but only a limited set of letters, so use the HTML tags when the character you need does not exist.
How do you write a chemical formula like H2O or CO2 in Markdown?
Use the <sub> tag for the numbers, for example H<sub>2</sub>O and CO<sub>2</sub>, which works where the renderer permits those HTML tags, including GitHub's current Markdown rendering. For a quick plain-text version, the Unicode subscript digits also work: H₂O and CO₂.
Which method should I use for subscript and superscript?
Use <sub> and <sup> HTML tags for portable, meaningful content, Unicode characters when you want no markup or need plain-text output, and the ~/^ shorthand only in a Pandoc or MultiMarkdown pipeline.
Does Reddit support superscript?
Yes, with a single leading caret and no closing caret, as in ^text, which raises the run until the next space. Wrap multiple words in parentheses, ^(multi word). Reddit does not support subscript.
How do you type the squared or cubed symbol?
Paste the Unicode characters ² (squared) or ³ (cubed) directly, or write <sup>2</sup> and <sup>3</sup> where inline HTML is allowed.
Sources and compatibility references
Use these primary references for syntax rules. Renderer behaviour can still vary by version and configuration, so preview important documents in their final destination.
Related pages
- Markdown documentation hub
- Strikethrough in Markdown
- Highlight text in Markdown
- LaTeX math in Markdown
- Inline HTML in Markdown
- Markdown flavors compared
