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 trialCatherine Wu
5,033 PointsWhy won't "text-decoration: none" work if i only use selector "nav" instead of "nav a"?
I was able to get nav a by trial and error, but just curious why selector "nav" won't return the same result. Thanks in advance!
3 Answers
Steven Parker
231,248 PointsSome properties are inherited from parent elements, and some are not.
It happens that "text-decoration" is one that is not inherited.
Fran ADP
6,304 PointsIt is because text decoration isn't inherited.
Catherine Wu
5,033 PointsI see. Thanks for your help! :)
Zimri Leijen
11,835 PointsSome properties are inherited from parent elements, and some are not.
It happens that "text-decoration" is one that is not inherited.
This is true.
nav a will target the anchor element that is a child of nav, while nav will target the nav element itself.
Some properties would be inherited, but not all.
On top of that you would target the parent container which targets more than you intended.
Catherine Wu
5,033 PointsI see. Thanks for your help! :) Does that mean we should always be as specific as possible when it comes to using selectors?
Zimri Leijen
11,835 Pointsin general, yes.
Catherine Wu
5,033 PointsCatherine Wu
5,033 PointsI see. Thanks for your help! :)