Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

HTML How to Make a Website Responsive Web Design and Testing Refactor the Layout

Onaje Baxley
Onaje Baxley
8,302 Points

Inside the media query, clear the left side of every 4th list item in the gallery.

I'm not sure why I can't pass this challenge. I've tried both the nth-child() and nth-of-type() selectors and given them arguments including 4, 4n, 4n+0, and 0n+4, but it seems as if i've hit a brick wall. It the error log is asking me if I made sure I cleared the left side of every 4th list item and I'm 99% sure that clear: left does just that. And yes my exact selectors were inside the same media query as challenge 1 of 2. I used this selector: #gallery li:nth-....() { clear: left; }

2 Answers

#gallery li:nth-child(4n){
  clear:left;
}

putting that inside the media query should work.

What is the difference between:

#gallery li:nth-child(4n){
  clear:left;
}

and:

#gallery li:nth-child(4){
  clear:left;
}

Thanks in advance for an answer.

Keith Kelly
Keith Kelly
21,326 Points

If you write the expression with only a 4, then it will select the 4th element and only the 4th element. If you use 4n it will select the 4th, 8th, 12th, ect. elements.

mrx3
mrx3
8,742 Points

actually there's some notes that are at the bottom of the video. I messed up with someone else asking the same question, and I was pointed to the notes at the bottom of the video the code is supposed to be. I know you asked about the test, and what Travis wrote is correct. I just wanted you to be aware of the fact, I'm just trying to be kind.

#gallery li:nth-child(3n+1) {
   clear: left;
}