CommonMark has no superscript or subscript. The HTML tags <sup> and <sub> are the portable choice; for anything that is really a formula, math notation gives better results.
All ways to write it
Superscript with HTML. Works on GitHub.Needs HTMLx<sup>2</sup>
Subscript with HTML.Needs HTMLH<sub>2</sub>O
Pandoc and some editors (Typora, markdown-it plugins).Some tools onlyx^2^ and H~2~O
Math, in tools that render it. Use for formulas.Some tools only$x^2$ and $H_2O$
Example
You type
E = mc<sup>2</sup>, and water is H<sub>2</sub>O.
See the footnote<sup>1</sup>.You get
E = mc2, and water is H2O.
See the footnote1.
Questions
Does ^text^ work on GitHub?
No. GitHub shows the carets as typed. Use <sup>text</sup>.
How do I write a footnote marker?
Use real footnote syntax, text[^1], where the tool supports it; it numbers and links the note for you. See the footnotes page.
Superscript, subscript in Confluence
For formulas, Markdown Macro+ renders $x^2$ and $H_2O$ with KaTeX. Outside the macro, LaTeX Math for Confluence adds inline and block equations to any page.