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 trialnathan marq
1,939 PointsHow 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
35,909 PointsAll 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.
Joe Bruno
35,909 PointsHere is an example: http://blog.circleci.com/adaptive-placeholders/
Nolan Figueroa
8,312 PointsHere's another link that may help: http://css-tricks.com/attribute-selectors/
nathan marq
1,939 Pointssweet 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 >, +, ~