CSS CSS Basics Understanding Values and Units Em Units

Corey Rodney
Corey Rodney
3,075 Points

When and why most people use EM over px

After doing some research on my own I notice that in the header most if not all use em over px. My question is since they both do the same thing is there a benefit for using em over just simply using px?

1 Answer

Steven Parker
Steven Parker
177,579 Points

An advantage of using "em" units is when you are sizing something that contains text, it will grow or shrink to remain proportional to the text if the font size is changed at a later time.

Pixel units are a good choice when you want to size something that won't change, such as an image container.