When I need to ask questions, occasionally, I'll need a super or a subscript letter or number for pseudo-code or math equations.

I've seen this done in answers of this question: Special superscript characters

I've gone through the formatting page and for the life of me I can't figure it out.

  • 2
    For future reference, you can view the source of any question by clicking the 'edit' button below it (or the 'improve this answer' if not logged in). Sep 14, 2013 at 17:51
  • Although, in that example, it's not superscript, it appears to be some unicode derivative. Sep 14, 2013 at 17:52
  • That question uses the actual Unicode codepoints for superscript characters; it’s not just formatting. If you want a superscript 2, for example, there’s one of those: ² Works in comments, too.
    – Ry-
    Sep 14, 2013 at 17:59

4 Answers 4


Use <sup> and <sub>:

This is a <sup>superscript</sup>  
This is a <sub>subscript</sub>

This is a superscript
This is a subscript

Using <pre><code> blocks, because they're strange, lets you do this as well:

<pre><code>This is a <sup>superscript</sup>  
This is a <sub>subscript</sub></code></pre>
This is a superscript  
This is a subscript

But it's an evil hack and I wouldn't recommend it.

  • Okay, so is that only usable for regular text? From your example it seems as if it doesn't apply to the code section. Sep 14, 2013 at 17:51
  • @PaulBakerSaltShaker correct - the point of a code block is to show the source. If you put it inside a <pre><code> block however, or use unicode like the other question did, it is possible to have them in there, let me edit my answer for an example. Sep 14, 2013 at 17:52
  • Okay thanks, I get it now. This makes a lot more sense than it did before. I appreciate the clarification. Sep 14, 2013 at 18:02
  • 2
    Oooooh! Evil hacks are fun to know. Sep 14, 2013 at 23:28
  • 4
    Do <sup>sup</sup> and <sub>sub</sub> work in comments, too? Crap. No. Jul 16, 2014 at 22:28
  • 1
    @DavidConrad I notice that on biology.stackexchange.com you can do $O_2$ and it will do the 2 as subscript.
    – barlop
    Mar 17, 2017 at 4:16
  • Broken on May 18, 2017. May 18, 2017 at 14:46
  • @barlop CO_2 doesn't work within a math equation on Chemistry Stack Exchange but CO_{2} does. Jan 4, 2019 at 22:40

As this answer to that question says

For instance, here on SO, you could use: demo superscript ABC
That's the output of <sup>demo superscript ABC</sup>

You can also use <sub>…</sub> for subscripting.


In the new Stacks Editor the shortcuts for the Superscript Ctrl-. and Subscript Ctrl-, are introduced. Reference: https://github.com/StackExchange/Stacks-Editor/issues/51
Using the new shortcuts you are able to create the Superscript and Subscript texts.

Screenshot for reference:

Superscript, Subscript image

GIF for reference:

Superscript, Subscript gif


You can use Unicode superscript numbers (⁰¹²³⁴⁵⁶⁷⁸⁹) or html <sup>2</sup> (but that doesn't work in comments). It seems that some parts of SE are using something called mathjax to render math symbols / formulas including superscript. Here are some examples, but they won't work unless mathjax is enabled.

  • For example, this doesn't work here on meta.stackexchange: $x_i^2$, bit it will work in math for example. Nov 26, 2018 at 19:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .