# Writing Fractions In HTML 2

Fractions are an important part of science mathematics. A fraction is a representation of one number divided by another. On paper, they are written with two numbers arranged vertically with a line separating them. The top number (numerator) is divided by the bottom number (denominator). One half is 1 divided by 2 and is expressed as 1 over 2 with a line between them: ½.

Unfortunately writing fractions in HTML is a little tricky. Text on web documents is written straight across with where only one character can take up one space on the line. Characters can be moved vertically, but cannot have another character immediately below them. To write a fraction, people write fractions with a slash symbol (/) between the numbers.

3/4 – three fourths
1/2 – one half
5/9 – five ninths
99/100 – 99 hundredths

There is a better way. These same fractions can look like ¾, ½, 59, and 99100.

If your fraction is a simple one with a single digit numerator and a single digit denominator, you can often use the &fracxy; code where x is the numerator and y is the denominator.

&frac12; is ½
&frac13; is ⅓
&frac23; is ⅔
&frac14; is ¼

Not all single digit numbers work with this command. For example &frac26; shows &frac26 in a browser, not 26.

For these cases, and for fractions involving larger numbers, there is a trick you can use. The HTML code &frasl; draws the fraction slash. Think &fractionslash; to remember it. The format for this is:

<numerator>&frasl;<denominator>

This will give a result similar to using the slash key. The only difference is the angle the dividing line takes and how close the numbers are to the line. For example, five ninths looks like:

slash (/) key:   5/9
&frasl; code: 5⁄9

The effect can be improved by adding the superscript and subscript formatting to the numbers. Add the <sup></sup> code around the numerator and <sub></sub> around the denominator.

<sup>5</sup>&frasl;<sup>9</sup> looks like 59.

This looks much better. With this trick, you can express any fraction inline with your HTML text.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

## 2 thoughts on “Writing Fractions In HTML”

• Todd Helmenstine Post author

You are absolutely correct.
I have edited the post where the word ‘into’ is replaced with the word ‘by’.
The top number (numerator) is divided by the bottom number (denominator).
Thanks for bringing it to my attention.