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 CSS Foundations Selectors Basic Structural Pseudo-Classes

Randy Preising
Randy Preising
3,254 Points

Stuck on basic structural pseudo-classes challenge

Not sure what I did wrong here. Any ideas?

index.html
<!DOCTYPE html>
<html>
<head>
    <title>Structural Pseudo-Classes</title>
    <link rel="stylesheet" href="page.css">
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <ul>
        <li>First child of ul</li>
        <li>Second child</li>
        <li>Third child</li>
        <li>Fourth child</li>
        <li>Last child of ul</li>
    </ul>
</body>
</html> 
style.css
/* Complete the challenge by writing CSS below */

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

2 Answers

There should not be a space between the colon and pseudo selector:

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

I think of the pseudo element as being attached to the main element.

Randy Preising
Randy Preising
3,254 Points

Thank you! I guess I got too used to putting a space after the colon.