All Comparisons
Winner: REM

PX vs REM vs EM in CSS

Comparing CSS units for web typography and layout. Which is best for accessibility and responsive design?

REM
EM
Relative To
Root element (<html>) font-size
Parent element font-size
Accessibility (User scaling)
Poor (fixed size)
Excellent (scales with user preferences)
Compounding Issues
None (always relative to root)
High (sizes compound if nested)
Best Use Case
Typography, spacing, layout
1px borders, fixed constraints

When to use which?

Typography and Global Spacing

"Setting font sizes, margins, and padding across a web application."

RecommendationUse REM. It ensures that if a visually impaired user increases their browser default font size to 24px, your entire site scales proportionally without compounding issues.

Component-Level Scaling

"Building a button component that needs to scale its internal padding perfectly based on its own font size."

RecommendationUse EM. Setting padding in EM allows the button to scale up perfectly just by changing the font-size of the button class.

Read the Deep Dive

We wrote a comprehensive technical guide covering this exact topic in extreme detail.

Read Article

Frequently Asked Questions

Q.Why should I stop using PX for fonts?

A.

If you set a font size to 16px, it is hardcoded. If a user changes their browser default font size to 24px for accessibility reasons, your 16px text will not change, breaking accessibility.

Q.What is the default browser font size?

A.

In almost all modern browsers, the default root font size is 16px. Therefore, 1rem = 16px by default.