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

Bug in CSS selector challange

challange was: "Select the li that is the first child of the ul. Set the color to white and background color to black." Tried to complete it many times before discovering that you can only pass the exercize if you set the background color to "blak". Writing black corrertly will fail to pass the challange.

EDIT: Can't pass it even writing "blak", the only difference is that when i write "blak" the value change it's color to orange while when I write "black" the value change the color to red. now i'm literally stuck there.

12 Answers

Have you tried

ul li:nth-child(1) {
    color: white;
    background-color: black;
}

?

Pedro! Thanks, that worked! The only problem it's that in the basic selectors course there's no lesson about the :nth-child() pseudo class. Do you know if there's a way to report the problem to the staff? Thanks again!

EDIT: How can I mark your reply as Answer?

Can you post here the code that you wrote in this challenge ?

            /* Complete the challenge by writing CSS below */

ul:first-child {
    color: white;
    background-color: black;
}
            ``` 

Also tryied with #HEX black and rgb() black but nothing.

Also, if I preview preview the result I see all the li elements in white and with black background. Don't think it's an error/ typo on my side...

You are welcome Federico, what is exactly the name of the course that you are taking ? Is it from a track or a single one from the library ?

It's the "Selectors" Achievements. I'm on the Web Design Track, inside the CSS Foundation deep dive.

OK, Federico In this track the nth-child was presented in the First Project: How to Make a Website -> CSS: Cascading Style Sheets -> Use ID Selectors. By the way, can you please put "best answer" for my first one ? Thanks a lot. Enjoy the rest of the track. :)

I would love to put "best answer" but, I you can see here http://imageshack.com/a/img853/2646/kao8.jpg i don't have any option to do so! I can see that option only in discussion that are started by someone else..

Federico Cocheo Filetti -

When you started this thread you left the category as general discussion. Threads in that category don't have voting or best answers. However if you changed this thread to CSS it would have a best answer button.

No worries Federico. I hope I helped. Tks.

Hope someone will come and give you your deserved "best answer", thanks again Pedro!

Hi Frederico and Pedro

You can't award a best answer for "general discussion". If the question was posted under "CSS" or another specific topic then you would be able to.

Hope this helps!

Hi Federico,

I know you have it solved but just to let you know, :first-child should work here. The only problem you had in your selector was that you were selecting a ul that was a first child. Not an li within a ul

ul li:first-child {
    color: white;
    background-color: black;
}

You can use :nth-child(1) but that is the same as :first-child

Thanks for the information Tom.

Jason, thanks for clearing. I've managed to get that solved later. I was writing "ul:first-child" because to me, translated in plain english was something like: "select the first child of all ul's elements" when instead I should have written "select all the list items that are first child of an unordered list" or: ul li:first-child {}. Thanks for clarification.