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

Diego Hidalgo
seal-mask
.a{fill-rule:evenodd;}techdegree
Diego Hidalgo
Front End Web Development Techdegree Student 13,778 Points

I didn’t understand margin collapsing

I didn’t understand the margin collapsing well, the margin of h1 exits outside the container because it doesn’t inconvenience the padding and the Boder of the parent container. I tried with a div and p using the same "settings" css and what was explained does not happen, the p you take the space inside the parent div. It is explained that the margin collapses because of incotra the body’s margin, but if the body has margin:0; actually there is no margin with which the h1 margin can meet and then collapse so that the one with a larger value is set

1 Answer

Jamie Reardon
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jamie Reardon
Treehouse Project Reviewer

Hi Diego Hidalgo margin-collapse refers to the top / bottom margins of elements sometimes combining (collapsing) into a single margin if they are equal. You can read more here on the concept.