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 CSS Foundations Selectors Basic Attribute Selectors

How can you tell when to use attribute selectors ???

To all the JEDI coders out there ... what would be a situation that would cause you to used class attribute selectors and why ???

3 Answers

Joe Bruno
Joe Bruno
35,909 Points

All of those selectors are essentially local - direct descendent, sibling, adjacent. Sometimes you need something more universal in scope such as input[type=email] even if this is to replace existing styling on that element - happens a lot in WordPress plugins.

sweet thanks ... that helped clear things up a bit ... but ... is that the lazy mans way of selecting something ??? I am not trying to be offensive I really am wanting to understand WHY that approach would be better than using one of these >, +, ~