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 trialJanet Leon
6,908 PointsClearing 4th item
Why exactly do we need to clear the 4th item? Can we get a more detailed explanation?
1 Answer
Jonathan Grieve
Treehouse Moderator 91,253 PointsHi there,
You need to provide something called a clearfix and then select the element with something called an nth child selector.
:nth-child(4);
So here's the CSS you need to clear floats on an element.
selector {
display: table;
content: "";
clear: both;
}
That's a clear fix. Now to clear every 4th item you need to provide the selector that selects every 4th item in sibling elements.
To do this you simply provide the seletor i procises avoce as a pseudo element. http://stackoverflow.com/questions/16948286/selecting-every-4th-div
So you'd use your selector (I'm not sure which one you need precisely, and then use a colon (:) to add the nth child selector to it,
e.g.
selector:nth-child(4) {
display: table;
content: "";
clear: both;
}
Remember to add the peusdo selector to a group of list items rather than their containing element.
Hope this helps :)