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 trialSandeep Maheshwari
Courses Plus Student 207 PointsStill 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
tylerduprey
Full Stack JavaScript Techdegree Student 25,399 PointsHi 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/