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 Framework Basics Build a Website with Foundation Visibility Classes and Column Ordering

px, em and rem

I am confused about when you choose to use px, em or rem. In this video, you used em's for the first time for the margin setting of the .th_logo class. You have been using px. Why did you switch? It seems like Foundation uses mainly em and rem, are there compatibility issues when you use px as well?

1 Answer

Juliana Madrone
Juliana Madrone
8,552 Points

Hi Anna, My understanding is that em and rem are usually better choices because they are relative units. This means that if you are building a responsive website that adjusts its layout depending on the size of the browser or device it is being viewed on, the units will adjust as well and preserve your web design. If you use px, these are absolute units, so they will remain the same size no matter how your viewport changes. There may be times when you want this kind of absolute sizing and so you can use px then.

Hope that helps!