What is the difference between em and rem units?
Unit Relative To Example
em Parent’s font size 2em = 2 × parent
font-size
rem Root (<html>) font
size
2rem = 2 × root font-size
Example:
html { font-size: 16px; }
p { font-size: 2rem; } /* = 32px */
Key Takeaway:
Use rem for consistent sizing across the document.