Pixels to REM calculator

The default WordPress theme Twenty Sixteen is clean, simple, and responsive; as such it makes a perfect “starter” theme for all but the most arcane designs.

However, it uses REM — a.k.a. relative em units — for the all the measurements and sizing in its stylesheet and, unfortunately, unless one is a genius, REMs have to be calculated instead of intuited. Hence the point of a pixels to REM calculator, something you had no idea you needed until this very moment:

Pixels
REM

The one on Foliovision’s site is great (and the inspiration for this post). I wrote my own version here because I wanted to figure out how it worked.

For those who are similarly curious, the pixel value is multiplied by 10 to the eighth power, divided by the REM base of 14, then divided by 10 to the eighth power. View source and search for “welcome fellow nerds” if you want to see the Javascript.

The resulting REM value is usually a distressing 10 digits long, looking like PI’s red-headed second cousin, except when the pixel value is cleanly-divisible by 14. In those rare cases the REM is just a normal number and, honestly, it’s way more satisfying than probably I should be admitting here.

Looking to convert REM to pixels?