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) The Box Model Margins

Sunshine Khawaja
Sunshine Khawaja
1,845 Points

H2 margin decreases the space b/w the paragraph below. So far we've been using margin to increase space b/w elements.

In this video we're adding a margin-bottom of .5em to the H2 element. This actually decreases the space between the H2 and the paragraph below. So far we have just used margin to push away other elements, so can someone explain why this actually does the opposite in this instance? Is it because it's an H2 and automatically has more margin around it because it's a block element? Also, would adding margin-top to the p element do the same thing?

Aaron HARPT
Aaron HARPT
19,845 Points

It is because 0.5em for margin is less than the default margin which is around 0.85em so a value of 0.5em would be a slight negative making the elements closer to each other. Also, margin-top on the p element would do the same thing.

Hope that helps.

1 Answer

Sunshine Khawaja
Sunshine Khawaja
1,845 Points

That's the exact answer I was looking for. I didn't know what the default margin was so thanks so much!