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

hover state

The test said to change navigation link on hover. I tried a:hover and nav:hover but only nav a:hover was the correct answer. Why?? It seems that the other codings give the same results.

2 Answers

Laura Cressman
Laura Cressman
12,548 Points

Hi Pgmd, I think the reason that the nav:a was needed was because we want to target links in the navigation specifically. Using just nav would make everything in the nav element change it's CSS properties on the hover state (like the unordered list, for example), while using just a:hover would make all links on the page, even those that were not in just the navigation bar, change when you hovered over them. Hope that helps, let me know if you have any further questions! Smile, Laura :)

Janek Rezner
Janek Rezner
12,973 Points

well because you might have other links then ones nested in your nav bar on your page.

by doing a:hover you are selecting all links on the whole page.