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!
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
What is the point of this?
Sorry guys, but this is bothering me. After watching a handful of videos and doing some attribute selectors, Guil switches back to class selectors, working backwards to give some neat styling to a few buttons. Again, I don't see the value in creating a class selector then going back to your HTML when you can target everything in the CSS with a few attribute selectors. It all seems a bit pointless to me as far as DRY goes.
Jamie Moore3,997 Points
Attribute and class selectors are both great for different reasons. Using class selectors lets you apply styles to anything with that class. Using attribute selectors is very specific.
If you're styling buttons across a whole website, you might want all buttons to look the same regardless of their actual element. For example, your a tags, your submit form buttons, and any other button tags. Using class selector makes it easier to apply those styles to each of the different use cases, whereas an attribute selector would need to be applied to any element. In most use cases, you'll use a class selector because they can be re-used over and over again.
I hope that made some sense.
Joshua Graber11,785 Points