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 Selectors Going Further with Attribute Selectors and Pseudo-Classes :first-child and :last-child Challenge

Tom Williams
Tom Williams
5,270 Points

How do I create a pseudo-class selector that targets the first-child li in main-nav? Some syntax I'm missing...

This one has had me stumped for days. I get targeting li:first-child {} but targeting an li that is within a class is a mystery

style.css
/* Complete the challenge by writing CSS below */
.main-nav li:first-child {
    border-style: none;
    border-top-left-radius: 5px;
    border-bottom-left-radius: 5px;
  }
index.html
<!DOCTYPE html>
<html>
<head>
    <title>Selectors</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href='http://fonts.googleapis.com/css?family=Nunito:400,300' rel='stylesheet' type='text/css'>
  <link rel="stylesheet" href="page.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
    <header>
      <h1>My Site!</h1>
      <ul class="main-nav">
        <li><a href="#">Home</a></li>
        <li><a href="#">About</a></li>
        <li><a href="#">Work</a></li>
        <li><a href="#">Contact</a></li>
      </ul>
    </header>
    <div>
      <p>Tattooed viral put a bird on it skateboard. Drinking vinegar locavore squid farm-to-table, dreamcatcher tattooed kitsch scenester. Tousled wolf squid Wes Anderson PBR, Williamsburg banh mi dreamcatcher stumptown ethnic sartorial mlkshk. Hella mixtape bespoke mustache Bushwick. Post-ironic hashtag jean shorts, Truffaut organic roof party pop-up wayfarers selvage narwhal. Mixtape roof party twee, post-ironic bespoke hella artisan meggings Carles brunch pop-up Tonx street art normcore. DIY paleo slow-carb occupy tofu fingerstache.</p>
    </div>
</body>
</html>
Tom Williams
Tom Williams
5,270 Points

In preview mode my attempt appears to work but it gets rejected by the code challenge

2 Answers

Hi, i think the problem lies with the border radius. This code just passed the challenge .main-nav li:first-child { border: none; border-radius: 5px 0 0 5px; }

Reason being the border radius properties work clockwise starting from the the top left of the element therefore top left 5px top right 0px bottom right 0px bottom left 5px

Tom Williams
Tom Williams
5,270 Points

Thanks Richard. Though my method worked it appears the better method is doing all four sides in one statement...if passing the code challenge is any indicator.