Can someone explain to me the way pixels relate to rem? How does my
browser decide the number of pixels in a rem unit?
rem
stands for root-em which is the font-size of the root element. In HTML the root element is <html>
. UAs usually apply a font-size
of 16px
to html
, Therefore 1rem
would be equal to 16px
in that case.
5.1.1. Font-relative lengths: the ‘em’, ‘ex’, ‘ch’, ‘rem’ units
Aside from ‘rem’ (which refers to the font-size of the root element),
the font-relative lengths refer to the font metrics of the element on
which they are used [...]
rem unit
Equal to the computed value of ‘font-size’ on the root element.
When specified on the ‘font-size’ property of the root element, the
‘rem’ units refer to the property's initial value.
And the initial value of font-size
is medium
.