7.4k views
0 votes
Should you use rem or em in font sizes?

User SSA
by
6.9k points

1 Answer

1 vote

Final answer:

Choosing between rem and em for setting font sizes depends on the context; rem offers consistent scaling relative to the root, while em is relative to the parent and can lead to compound scaling issues. Rem is better for global styling and maintaining proportions, while em is suited for element-specific adjustments.

Step-by-step explanation:

When it comes to setting font sizes in web design, the units of measurement you choose can make a significant difference in scalability and responsiveness. The debate between using rem and em has been ongoing among developers and designers. Both have their advantages and appropriate use-cases.



The em unit is relative to the font-size of its parent element. This can be both an advantage and a drawback. It's beneficial when you want to scale the UI elements proportionally as you change a parent element's font-size. However, the compound effect can become an issue if you nest elements with em-based sizing, potentially leading to unpredictably large or small font sizes.



On the other hand, the rem, which stands for 'root em', is relative to the root element's font-size, commonly the element. This provides a consistent reference point and avoids the compounding problem. Using rems makes it easier to maintain uniformity in your design and is helpful when building a modular design system. If you need to adjust the base font size, all elements scaled in rem will adjust accordingly, maintaining their relative proportions.


User Deniz
by
7.4k points