Using the Unicode Fraction Slash instead of HTML sub/sup tags

 
 
  • Gérald Barré

When you need to display fractions in HTML, you might reach for the <sub> and <sup> tags. However, there's a simpler Unicode-based alternative: the fraction slash character (U+2044).

#What is the Fraction Slash?

The fraction slash (⁄) is a Unicode character that automatically formats surrounding digits as a fraction. When placed between two digits, most modern browsers and fonts render it as a proper fraction, with the numerator raised and the denominator lowered.

#Example

Instead of writing HTML like this:

HTML
<sup>1</sup>&frasl;<sub>2</sub>

Or this:

HTML
<sup>1</sup>/<sub>2</sub>

You can simply use:

HTML
1⁄2

Both will display similarly, but the Unicode approach is cleaner and doesn't require any HTML tags.

#More Examples

  • 1⁄2 (one half)
  • 3⁄4 (three quarters)
  • 123⁄456 (complex fraction)
  • 22⁄7 (approximation of π)

#Browser Support

The fraction slash character is well-supported in modern browsers. Automatic fraction formatting relies on OpenType font features and may vary between fonts, but the character itself always renders correctly.

#When to Use It

The fraction slash is perfect for:

  • Simple fractions in body text
  • Technical documentation
  • Mathematical expressions where you don't need full MathML support

However, for more complex mathematical notation, you might still want to use proper math rendering libraries or MathML.

#Additional resources

Do you have a question or a suggestion about this post? Contact me!

Follow me:
Enjoy this blog?