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.

CSS

Alan Shahry
seal-mask
.a{fill-rule:evenodd;}techdegree
Alan Shahry
Full Stack JavaScript Techdegree Student 23,184 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

Brandan Booth
Brandan Booth
8,846 Points

this should work i just tried it

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

Brandan Booth
Brandan Booth
8,846 Points

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.