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

What is the benefit from using an attribute selector over an ID selector?

Wouldn't using an ID selector provide a higher level of specificity and maintain a cleaner and more simplified HTML and CSS?

2 Answers

Hey Devon,

I also found this article on the topic from CSS tricks that you may find helpful:

https://css-tricks.com/attribute-selectors/

It explains a few instances and real world examples of why you might benefit from using an attribute selector.

Cheers!

Yes you are right. But you want to limit your use of IDs. Alt selectors are great, and the purpose of the lessons of it here on Treehouse, is to teach you how to be able to style your website even if you have limited or no access to HTML.

Hope that helps abit.