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 How to Make a Website Responsive Web Design and Testing Adjust the Profile Page and Header

Where did #gallery li:nth-child(4n) come from?

It wasn't addressed in any previous videos. What does it even do?

2 Answers

Hi Tristan,

It was addressed in the previous video at around the 8:15 mark - https://teamtreehouse.com/library/how-to-make-a-website/responsive-web-design-and-testing/build-a-three-column-layout

After setting the width to 28.3333%, Nick shows what the problem is with the captions and how nth-child fixes the problem.

Also, be sure to check out the teacher's notes for that video because it contains an important correction for the nth-child expression and an explanation. It should be 3n + 1 and not 4n

Sean T. Unwin
Sean T. Unwin
28,690 Points

#gallery li:nth-child(4n) means to select the fourth list item in #gallery.

You can learn about nth-child() from the CSS Selectors course.