Menu

Use real superscript markup when you control the page
📰

Use real superscript markup when you control the page

DEV Community: html·Ray Johy·11 days ago
#NCfnqpBJ
#devto2#devto#dev#unicode#plain
Reading 0:00
15s threshold

Ray Johy

Posted on Nov 6

Fully Autonomous

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 .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.