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 CSS Layout CSS Layout Techniques Display

Cosimo Peronace
Cosimo Peronace
4,869 Points

By default list items are placed on individual lines. Write a selector to target the list items with a class of .nav-btn

Hey guys,

I am completely stuck on this question. When I preview the code, to me it looks like the buttons are inline

style.css
/* Complete the challenge by writing CSS below */
.more {

  display: none;

}

.nav-btn li {
  display: inline-block;
  width: 120px;

}
index.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
    <title>CSS Layout</title>
    <link rel="stylesheet" href="page.css">
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div class="container">
    <header>
      <nav>
        <ul class="nav-btn">
          <li class="nav-btn"><a href="#">Donuts</a></li>
                  <li class="nav-btn"><a href="#">Tea</a></li>
                  <li class="nav-btn"><a href="#">Coffee</a></li>
        </ul>
      </nav>
    </header>
    <main>
      <article>
        <h1>Donuts</h1>
        <p>Donuts are sweet snacks usually deep fried from a flour dough. The best place to buy donuts is at a bakery or specialty donut shop. Donuts go great with coffee.</p>
        <a href="#">Read more</a>
        <p class="more">In this paragraph, you’ll learn lots more interesting facts about donuts. For example, did you know that the largest donut ever made was a jelly donut weighing more than one and a half tons? It measured 16 feet in diameter and 16 inches high in the center.</p>
      </article>
    </main>
  </div>
</body>
</html>

1 Answer

mouseandweb
mouseandweb
13,729 Points

Hello Cosimo Peronace ,

In your CSS you selected the li that's a child of an element with class "nav-btn". Seeing as the <li> elements already have the class "nav-btn" you do not need to specify the element itself.

So your code for the list elements should look like this:

/* targeting the elements with class "nav-btn" */
.nav-btn {
  display: inline;
  width: 120px;
}

What you wrote was this:

/* targeting any <li> elements that are children of an element with the class "nav-btn" */
.nav-btn li{
  display: inline;
  width: 120px;
}

In your HTML there is no <li> that's a child of an element with the class "nav-btn" so nothing is affected.

Cosimo Peronace
Cosimo Peronace
4,869 Points

Thank you so much!! This makes much more sense now!