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.

General Discussion

About code challenge

Try to add nav class and selector ul li .

I dont know what im doing wrong. Watched video couple times, but cant get this right. Please help.

6 Answers

James Barnett
James Barnett
39,199 Points

The key to this question is to understand that the <ul> element has a class of nav, in other words it's <ul class = "nav">.

So the HTML would look something like this:

<ul class="nav">
  <li></li>
</ul>

Now ask yourself ... what is the CSS selector I would use to select all <li>s from the above markup?

If you are unclear on how to do that, consider checking out the Learn HTML & CSS learning adventure.

ul li .nav It would be all li selected with in ul with class nav. But It is a code on Jquery. $("ul li").addClass("nav");

James Barnett
James Barnett
39,199 Points

What's the link to the code challenge you are having issues with?

James Barnett
James Barnett
39,199 Points

For reference the instructions are:

On the next line, use jQuery to select all list items (li) in an unordered list (ul) with the class of 'nav'?

Note the directions, make no reference to adding a class with JQuery, but instead referencing a class with CSS.

So giving this HTML:

<ul class="nav">
  <li></li>
</ul>

Hint: Use the most specific CSS selector.

Thank you finally I got it