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


Alan Shahry
Alan Shahry
Full Stack JavaScript Techdegree Student 23,574 Points

Basic Structural Pseudo-Classes

In this drill I have a <ul> with <li>first child of ul</li> and I am asked to set the background color for the <li> to black and the color to white. My code in css is: li: first child of ul { background-color: black; color: white; }

but it keep saying that I still need to set the background color to black. What do you think is the problem?

3 Answers

this should work i just tried it

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

this should help you out

color:white; background:black;

James Barnett
James Barnett
39,199 Points

Arash Shahry -

Maybe I'm misunderstanding what you posted but li: first child of ul is not a valid selector. li:first-child however is valid.

Check out the section on structural pseudo-class in tutorial to learn more about the syntax of first-child.