📏 CSS

px vs rem vs em — Stop Guessing Which Unit to Use

📅 Jul 2, 2026 ⏱ 3 min read

The unit question has a clean answer once you know what each is relative to.

The decision table

The accessibility reason rem wins

Users with weak eyesight raise their browser's default font size. rem-sized text scales with their setting; px-sized text ignores it. Same for spacing — a rem-based layout scales gracefully. This answer in an interview signals you build for humans.

The mental math trick

html { font-size: 62.5%; }   /* 1rem = 10px — easy math */
/* OR just remember: 1rem=16, 1.5rem=24, 2rem=32 */

Full lesson: Complete CSS Guide §04.

← All Articles