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 Getting Started with CSS Layout Why Vertical Margins Collapse

Should the heading margin be interfering with the bottom margin edge of the body?

.

1 Answer

Steven Parker
Steven Parker
231,236 Points

There's two common kinds of margin collapse. Sibling collapse occurs between items positioned one over the other, involving the the bottom margin of the upper element and the top margin of the lower one.

Parent/child collapse occurs between an inner element and it's container, where both top margins (and/or both bottom margins) are merged together.

And there's actually a rare third case where the top and bottom margins of a single element merge when it has no content.

For more details, see the MDN page on Mastering margin collapsing.