"How to Make a Website" was retired on March 24, 2020. You are now viewing the recommended replacement.

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

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
241,488 Points

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

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

I see. Thanks for your help! :)

It is because text decoration isn't inherited.

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.

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.