box-modeleasy
What is the difference between em and rem?
Answer
rem is always relative to the root font size, so it stays predictable wherever the element sits. em is relative to the element's own font size, which means it compounds when nested — a common cause of text that shrinks or grows unexpectedly several levels deep. Use rem for type scales and spacing, and em when you deliberately want a value to scale with the component's own text.
Points an interviewer listens for
- rem: relative to root, predictable
- em: relative to the element, compounds when nested
- rem for global scale, em for component-relative sizing
- Both respect the user's browser font-size setting
Reported at
Similar questions have been reported by candidates at Ant Group, Digiryte, Ignxt Technologies, Mahe Technologies, muVerity, Neerx Technovation.
Now try answering it out loud
Interview practice mode times your spoken answer and checks it against the points above.
Practise this question