Question 6 of 10Pro Only

Explain the difference between px, em, rem, and percentage units in CSS. When would you use each one?

Sample answer preview

CSS offers different units for sizing, and choosing the right one depends on what you are trying to achieve. Let me explain each unit and when to use it. Pixels, written as px, are absolute units. One pixel is a fixed size that does not change based on context.

pixelsemrempercentagerelative unitsabsolute units

Unlock the full answer

Get the complete model answer, key points, common pitfalls, and access to 9+ more Frontend Developer interview questions.

Upgrade to Pro

Starting at $19/month • Cancel anytime