Mr. Alien Mr. Alien - 1 year ago 75
CSS Question

How does rem differ from em in CSS?

In website source, I have sometimes seen developers use the

unit. Is it similar to
? I tried it to see what it actually does, but what is it relative to?



<div>Hello <p>World</p></div>


div {
font-size: 1.4rem;

div p {
font-size: 1.4rem;

Answer Source

EMs are relative to their parent's font size

REMs are relative to a base font-size

This is important when intermediate containers change font sizes. Child elements with EMs will be affected, those using REMs will not.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download