CSS3 defines new a length unit for font-size
called rem
. This allow us to compute element's font-size
relate to the root element (html element).
To compute the font-size
more easily , we usually assume the root element's font-size
is 16px
, therefore the CSS usually ends up like this:
html { font-size:62.5%; } // 10px = 16px * 0.625
So, every element height with rem
is relative to 10px
, for example
p{ font-size : 1.4rem ;} // 14px = 10px * 1.4
I cant find why we assume we can multiply by 16px
? How can we trust every browser will have the same base value of 16px
? Is there is a standard description about the pre-defined 16px
?
Ref
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…