Rubenerd: Fractions in HTML

1 min read Original article ↗

I realised something recently: I rarely write fractions in my daily life. I might divvy up a pizza with friends, cut up pieces of round birthday cake, or refer to times as “quarter past five” instead of 17:15 in speech. But I somehow managed to avoid writing them after uni, until I started drafting posts about turntables, and I realised I needed a way to succinctly express the ubiquitous “33 and a third” speed.

One way is to construct one with:

  • A <sup> element for the divisor

  • A Unicode “fraction slash” (&#x2044;) as a more semantically correct forward slash for the fraction

  • A <sub> for the denominator

  • A <abbr> tag to explain the resulting mess for less visual readers

The result is something like the below:

13

Alternatively, today I learned you can express Vulgar Fractions in HTML using these codes:

  • &frac12; → ½
  • &frac13; → ⅓
  • &frac23; → ⅔
  • &frac14; → ¼
  • &frac34; → ¾
  • &frac15; → ⅕
  • &frac25; → ⅖
  • &frac35; → ⅗
  • &frac45; → ⅘
  • &frac16; → ⅙
  • &frac56; → ⅚
  • &frac18; → ⅛
  • &frac38; → ⅜
  • &frac58; → ⅝
  • &frac78; → ⅞

I’ve also added to the clipboard page on our wiki.