Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS CSS Basics (2014) 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
231,275 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.