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
federicococheofiletti
5,289 PointsBug 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
Pedro GCA
20,683 PointsHave you tried
ul li:nth-child(1) {
color: white;
background-color: black;
}
?
Pedro GCA
20,683 PointsCan you post here the code that you wrote in this challenge ?
federicococheofiletti
5,289 Points /* 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.
federicococheofiletti
5,289 PointsAlso, 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...
Pedro GCA
20,683 PointsYou 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 ?
federicococheofiletti
5,289 PointsIt's the "Selectors" Achievements. I'm on the Web Design Track, inside the CSS Foundation deep dive.
Pedro GCA
20,683 PointsOK, 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. :)
federicococheofiletti
5,289 PointsI 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..
James Barnett
39,199 PointsWhen 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.
Pedro GCA
20,683 PointsNo worries Federico. I hope I helped. Tks.
federicococheofiletti
5,289 PointsHope someone will come and give you your deserved "best answer", thanks again Pedro!
Tom Bedford
15,645 PointsHi 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!
Jason Anello
Courses Plus Student 94,610 PointsHi 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
federicococheofiletti
5,289 PointsThanks 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.
federicococheofiletti
5,289 Pointsfedericococheofiletti
5,289 PointsPedro! 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?