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 The Selectors Solution

Change the color of all list items inside an unordered list

When you change the color of list items using the selector "ul li {}", why does it only change the color of the list items in the <div class="list-primary"> tag and not the list items in the <nav> tag as well?

https://w.trhou.se/ntnzcbbcd4

1 Answer

Samuel Glister
Samuel Glister
12,471 Points

Hi Farzana,

The difference between the two is the 'ul li {}' is only targeting list items within an unordered list. In the navigation you have anchor elements inside the list item which by default will not take on this style.

If you want to target both list items and the links within them you could do something like this:

ul li, ul li a {
color: red;
}

Hi Samuel,

Thank you for your quick and helpful response!