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

Catherine Wu
Catherine Wu
5,033 Points

Why 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
Steven Parker
231,007 Points

Some properties are inherited from parent elements, and some are not.

It happens that "text-decoration" is one that is not inherited.

Catherine Wu
Catherine Wu
5,033 Points

I see. Thanks for your help! :)

Fran ADP
Fran ADP
6,304 Points

It is because text decoration isn't inherited.

Catherine Wu
Catherine Wu
5,033 Points

I see. Thanks for your help! :)

Some 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
Catherine Wu
5,033 Points

I see. Thanks for your help! :) Does that mean we should always be as specific as possible when it comes to using selectors?

in general, yes.