๐Ÿ“ 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