Junior From PDF JavaScript JavaScript

What is the difference between em and rem units?

Unit Relative To Example

em Parent’s font size 2em = 2 × parent

font-size

rem Root (<html>) font

size

2rem = 2 × root font-size

Example:

html { font-size: 16px; }

p { font-size: 2rem; } /* = 32px */

Key Takeaway:

Use rem for consistent sizing across the document.

More from JavaScript Tutorial

All questions for this course
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details