Ask any question about CSS here... and get an instant response.
Post this Question & Answer:
What's the difference between using rem and em units in CSS?
Asked on Apr 20, 2026
Answer
Rem and em units are both relative length units in CSS, but they differ in how they calculate size. Rem is relative to the root element's font size, while em is relative to the font size of the element itself or its parent.
Example Concept: The "rem" unit stands for "root em" and is calculated based on the font size of the root element (usually the element). In contrast, the "em" unit is calculated based on the font size of the current element or its parent. This means that "rem" provides consistent sizing across the entire document, while "em" can lead to compounding sizes if used in nested elements.
Additional Comment:
- Use "rem" for consistent and predictable sizing across different elements, especially for global styles like typography.
- "Em" is useful for scaling elements relative to their parent, which can be beneficial for component-based designs.
- Both units are responsive and adapt to user settings, making them preferable over fixed units like "px".
- Consider setting a base font size on the root element to easily scale the entire document using "rem".
Recommended Links:
