Explain advantages of rem and em over px in responsive design

This tests cascading font scaling and accessibility. Strong answers mention user zoom, root-level rem control, component em scaling, and avoiding px fragmentation. Red flag: claiming px handles all user preferences automatically.
What's really being asked
The interviewer wants to know if you understand the CSS length data type and how relative versus absolute units behave in real design systems. Specifically they care about accessibility, maintainability, and the cascade. They are checking whether you know that relative lengths represent measurements in terms of some other distance, such as font metrics or viewport size, while absolute lengths like px are fixed. The core issue is how a system responds when users change their browser font size or when the design needs to scale across devices.
The full answer
First, explain that rem is relative to the root element font size, which means changing the html font size scales the entire typography and spacing system globally without touching individual components. Second, explain that em is relative to the parent element font size, which is powerful for creating self-contained components where padding and margins stay proportional to the local text size. Third, mention that px is an absolute unit that does not respond to user font preferences in many browsers, which can break accessibility for users who rely on larger default text. Fourth, note that style sheets using relative length units can more easily scale from one output environment to another, such as from mobile to desktop or from screen to print. Fifth, discuss practical implementation: set root font size in px or use a percentage, then build the system in rem for global spacing and font sizes, reserving em for component-level internal proportions.
The mistakes people make
A major red flag is claiming that px is fine because modern browsers zoom the entire page, so relative units do not matter. This ignores users who change only the default font size without full page zoom. Another wrong answer is conflating rem and em without explaining the difference between root-relative and parent-relative behavior. Some candidates also argue that relative units are unpredictable, which reveals a lack of experience with design system architecture. Finally, stating that percentages are always preferable to rem or em shows confusion about when font-based metrics are more appropriate than container-based metrics.
What usually comes next
The interviewer may ask how you would handle third-party components that use px. They might ask about the relationship between rem and the html font size when the user has set a custom browser default. They could also ask about container query units like cqi or viewport units like vw, and when those are preferable to font-relative units. Another common follow-up is how to manage em compounding in deeply nested lists or typography.
A concrete example
Imagine a button component where the font size is set in rem and the padding is set in em. If the root font size is 16px, a 1rem font size equals 16px and 0.75em padding equals 12px. If a user changes their browser default to 20px, the button text grows to 20px and the padding grows to 15px automatically, keeping the visual proportions intact. If the padding had been set in px, the text would grow but the padding would remain 12px, making the button look cramped and breaking the design system consistency.
Interview question
When a user increases their browser's default font size without zooming, why do rem and em outperform px?
- a.em is relative to the root font size, while rem stays proportional to the parent element for local control.
- b.rem and em scale with font metrics, so text and spacing adjust automatically, while px remains fixed.Correct
- c.rem scales with viewport width, while em prevents cascading font-size issues in deeply nested components.
- d.Modern browsers automatically scale px-based text when users change the default font size, making relative units unnecessary.
Why? this is the answer
rem and em are relative to font metrics, so they adjust when a user changes their browser default font size, whereas px is absolute and does not. Option A is tempting because it uses the right vocabulary but incorrectly swaps rem and em, which is a common misconception the card explicitly warns against.
Just read this? Test yourself on what you have been reading.
Read the original → developer.mozilla.org
- #css
- #responsive-design
- #accessibility
- #design-systems
- #typography
You just looked this up. Could you explain it out loud?
That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on css — each one lists the topics its interview covers.
See open roles