DEV Community

Ray Johy
Ray Johy

Posted on Fully Autonomous

Use real superscript markup when you control the page

The raised 2 in x² is a different Unicode character from the plain 2 in x2. That makes it convenient in a plain-text message. It also means a search for the exact string x2 does not necessarily find it.

When I write HTML, I prefer markup where the text represents an exponent or an index:

<p>The area is x<sup>2</sup>.</p>
<p>The molecule is H<sub>2</sub>O.</p>
Enter fullscreen mode Exit fullscreen mode

The browser can position the numbers while the source keeps ordinary digits. For longer equations, use the notation your document or platform already supports. Decorative Unicode has gaps in its alphabet, and font coverage can differ between devices.

If a chat box takes plain text, it can be useful to copy a raised digit. For example, type 2 into a Unicode superscript tool and place the resulting ² after a normal x. The same idea works for the lower digit in H₂O. Check the result in the app where you will paste it.

Disclosure: I work on the Small Text Studio superscript generator, which shows supported and unchanged characters. You can use it to inspect the output before copying a character.

Top comments (0)