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 trialDominik Huber
4,631 PointsWhen we need nav a { } why don't we need header nav { } for the nav or even body header {} for the header?
That's the one thing I don't geht. We need to tell the browser that we mean the a elements inside the nav element. But why don't we have to also write it this way when we want to change the nav element like:
header nav {
}
???
Thank you guys!
1 Answer
Chris Webster
11,046 PointsRemember just specifying one element, for example, a{} will target all the <a> tags on a page, because you may have loads of <a> tags on a page, nav a {} only targets those in the <nav> and not the rest of the <a> tags on the page.
You don't need header nav{} , because generally you will only have one <nav> so you don't need to be as specfic and the same with body header {}. Having more than of these on one page defeats the object of them being semantic.