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

Still showing the scroll bar..

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

Why is there the above code in the CSS. Can anyone explain the above code please...

1 Answer

Hi Sandeep,

Paragraph tags have a top and bottom margin of about 1rem or 16px by default. This code tells the browser to remove the bottom margin of a paragraph if it is the last "child" of its "parent" element. In this case the <div> tag with the class "container" is the parent element. The third paragraph happens to be the "last-child" of the "container" div. So, that paragraph will not have a bottom margin because this code sets its bottom margin to "0".

Here's more about ":last-child" from CSS-Tricks: https://css-tricks.com/almanac/selectors/l/last-child/