There are alternatives to using
<sub> tags for superscripts and subscripts in HTML. These alternatives may look better, depending on context, and they can be used in plain (Unicode) text files where HTML markup isn’t available.
When I started blogging I would use
<sup>3</sup> for squares and cubes. Then somewhere along the way someone told me about
² (U+00B2) and
³ (U+00B3) and I started using these. The superscript characters generally produce slightly smaller subscripts and look nicer in my opinion.
Example with sup tags:
a2 + b2 = c2
Example with superscript characters:
a² + b² = c²
But there are no characters for exponents larger than 3. Or so I thought until recently.
There are no HTML entities for exponents larger than 3, nothing written in notation analogous to
³. There are Unicode characters for other superscripts up to 9, but they don’t have corresponding HTML entities.
The Unicode code point for superscript n is
2070hex + n
except for n = 2 or 3. For example, U+2075 is a superscript 5. So you could write x⁵ as
There are also Unicode symbols for subscripts, though they don’t have corresponding HTML entities. The Unicode code point for superscript n = 0, 1, 2, … 9 is
2080hex + n
For example, U+2087 is a subscript 7.
The subscript characters don’t extend below the baseline as far as subscripts in
<sub> tags do. Here are x‘s with subsubcripts in
x0, x1, x2, x3, x4, x5, x6, x7, x8, x9
And here are the single character subscripts.
x₀, x₁, x₂, x₃, x₄, x₅, x₆, x₇, x₈, x₉
I think the former looks better, but subscripts in HTML paragraphs may increase the vertical spacing between lines. If consistent line spacing is more important than conventional subscripts, you might prefer the subscript characters.