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 Layout Basics CSS Layout Project Creating and Styling the Layout Containers

John Haupenthal
John Haupenthal
2,749 Points

Why did you use em when setting padding and pixels when setting a bottom margin for the banner div?

Question says it all. Why use em for padding and pixels for margins?

iuliana sagaidak
iuliana sagaidak
4,797 Points

Because it's responsive, so in different size of devices it will change proportionally

2 Answers

For the vertical layout, we usually use pixel which is the unit by default, for the horizontal layout, we use percentage or em or rem (relative em) which helps with responsive layout.

iuliana sagaidak
iuliana sagaidak
4,797 Points

Because it's responsive, so in different size of devices it will change proportionally

John Haupenthal
John Haupenthal
2,749 Points

But then why use pixels for the bottom margin of the banner div?