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 Refactor the Layout

There is a bug in this coding challenge. Teacher notes state that it should be #gallery li:nth-child(3n+1)

Teacher notes state that it should be #gallery li:nth-child(3n+1) but coding challenge only accepts li:nth-child(4n)

Please forward this to a mod/staff.

2 Answers

Wayne Priestley
Wayne Priestley
19,579 Points

I don't think the coding challenges can except more than one answer, even if you type the correct answer but use a m instead of a M you will get the answer wrong. So I presume it compares what you write to a pre defined piece of text.

It was still a good find though Victor, you should email your findings to help@teamtreehouse.com and let them know. In the subject line mark it for the attention of whoever the teacher was.

Thanks! I'll do that.

Wayne Priestley
Wayne Priestley
19,579 Points

Hi Victor,

Thanks for bringing this up. I believe the correction to the code in the teachers notes is to allow your code to continue to work in the future when adding images to your site, something that was overlooked in the lesson. While the (4n) code will work, the new code is better for future additions.

The code challenge is asking for the code for that specific piece of code it has, so the (4n) code is exactly what's needed to pass. The tutorials and code challenges are not necessarily linked, they maybe similar but require slight different code making you think rather that simply copying the code from the lessons.

Hope this helps.

Thanks for the quick reply. I just double checked the coding challenge and the css still creates a 3 column gallery. So 4n will introduce the same bug as it did in the video where it will work for the first 4th element but when it gets to the 8th it will display like this:

1 2 3
4 5 6
7 
8 9 10

or possibly even like this if the 7 does not clear the caption properly

1 2 3
4 5 6
   7    
8 9 10

So as you said it will work for the specific code in the challenge since there are not 7 or more pictures but it will only work through luck, it's still incorrectly using the nth-child selector. Is it possible for the coding challenge to accept either 4n or 3n+1?

Thanks!