There are alternatives to using `<sup>`

and `<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.

## Superscripts

When I started blogging I would use `<sup>2</sup>`

and `<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:

*a*^{2} + *b*^{2} = *c*^{2}

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 `²`

and `³`

. 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

2070_{hex} + *n*

except for *n* = 2 or 3. For example, U+2075 is a superscript 5. So you could write *x*⁵ as

`<em>x</em>⁵`

.

## Subscripts

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

2080_{hex} + *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 `<sub>`

tags.

*x*_{0}, *x*_{1}, *x*_{2}, *x*_{3}, *x*_{4}, *x*_{5}, *x*_{6}, *x*_{7}, *x*_{8}, *x*_{9}

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.

## Related posts