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 Creating a Sticky Footer

Leandro Severino
Leandro Severino
12,674 Points

p:last-child was not explained?

I guess the code below was not explained that's why I was having a space between the wrap and the footer.

p:last-child { margin-bottom: 0; }

1 Answer

Steven Parker
Steven Parker
229,744 Points

The selector p:last-child targets only the last <p> element in a group of them that share the same "parent" (containing element), and the rest of it makes sure it has no bottom margin.

I'm guessing somewhere else a margin was established for the p elements, but they wanted the last one to have no margin.

But without seeing the rest of your code, I'm not sure why this would cause a problem.

Leandro Severino
Leandro Severino
12,674 Points

Thanks! Actually the problem is related to the margins collapsing when I implemented the sticky footer. Without it, there would be a space in between the footer and the wrapper(the content and the header).