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

Brady Gorman
seal-mask
.a{fill-rule:evenodd;}techdegree
Brady Gorman
Front End Web Development Techdegree Student 7,737 Points

ul li isn't working?

When I select the list item within the unordered list in the assignment, the properties aren't changing according to how I have them set. The answer video says the selector order is correct, but I can only get fonts to change when I specify the anchor (a) instead of the list item (li).

Very confused given I literally copy-pasted the final code for the assignment to see and even that won't change my text color.

ul li {
  color: lightcoral; /*-----font not lightcoral-----*/
}

ul a {
  color: lightcoral; /*-----font lightcoral-----*/
}
<header>
        <!-- LOGO -->
        <img src="logo.png" alt="Bookworm" id="bookworm">
        <nav>
          <ul>
            <li><a href="#">About</a></li>
            <li><a href="#">Articles</a></li>
            <li><a href="#">News</a></li>
            <li><a href="#">Get in Touch</a></li>  
          </ul>
        </nav>

1 Answer

Steven Parker
Steven Parker
229,005 Points

The issue here is inheritance. Some properties are inherited from the parent element, and some are not. And which is which depends on what kind of element it is. In particular, "color" is not inherited by anchor elements, so setting the color on a list item won't change the color of anchors inside it.

In the video, the list items are colored, but they are not anchors — just plain text in the list item.