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 Build a Three Column Layout

Andres Aguero
Andres Aguero
30,545 Points

Pseudo Element nth-child

In this video it describes the amount of time this style tag can help us by adding it unto our stylesheet.

gallery li:nth-child(4n){

clear:left; }

This was a bit unclear for me. I understood the affect it played in the website. But what happens if I would write the CSS as follows to the same website.

gallery li:nth-child(5n){

clear:left; }

or

gallery li:nth-child(7n){

clear:left; }

2 Answers

Ron McCranie
Ron McCranie
7,837 Points

Then you would clear the float at the 4th, 5th, and 7th child. It would look pretty odd, like this workspace

The selector will apply those attributes to every nth child so if you have a long list of paragraph elements then every 4th item would get selected and applied to.

Playground Example: http://codepen.io/anon/pen/yjncG