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

sebbe12
sebbe12
4,015 Points

One little nav detail made or break it I'm lost

ul li { color:tomato; }

nav a { text-docration:none }

nav a:hover { color:orange; }

.link:visited { color:red; }

.link:hover { color:green; } This code works fine -----------

ul li { color:tomato; }

a { text-docration:none
}

a:hover { ------- HERE if i remove nav here so it's a{ everything before and after turns out to be the same as how it was before i started writing code in this challange. color:orange; }

.link:visited { color:red; }

Question: why is the nav in nav a:hover {} so importent that it ruin the hole code?

https://w.trhou.se/ke5hhq4tcc

1 Answer

Steven Parker
Steven Parker
218,848 Points

The Container part ("nav") of your descendant selector restricts the rule to only the anchors that are inside that container. Without that, the rule applies to every anchor on the entire page, which is probably not what is needed.