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 Selectors Selectors - Beyond the Basics DRY CSS

dry css

on 8:25 he says that if we need to change the color of the button we just need to define a new class. why? we already have a class 'btn' ,don't we just need to add the styles that we want?

2 Answers

Hi.

I think Guil is just suggesting that you can get the best (most efficient) result from utilizing multiple classes on elements.

In this case, he's combining "btn default" and "btn error"

The btn class will have all the attributes the two inputs have in common, such as cursor: pointer, the default and error classes will have all the unique/distinct attributes that the two buttons do not have in common (what differentiates them), such as background-color. Does that make sense?

I hope that helps.

Stay safe and happy coding!

yes it does, tks!