Practical difference between rem and em units
Why would you use one of them? I know there are resources out there explaining the "difference", but what is a practical example where it would be better to use more em? And vice versa.
0
Jarg7
source
to share
2 answers
While em refers to the font size of its direct or closest parent, rem refers only to the html (root) size.
This is the most detailed explanation I can find on this topic. https://j.eremy.net/confused-about-rem-and-em/
+2
Shiva
source
to share
The CSS spec and level 3 values make it clear:
em: Equal to the computed value of the font-size property of the element in which it is used.
rem: Equal to the computed "font-size" value at the root element. If a root element's font-size property value is specified, "rem" units refer to the property's initial value.
+1
Dai
source
to share