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

Is it considered better to have cluttered HTML (assigning multiple classes to various elements) vs CSS (DRY)?

I understand the concept of DRY as far as keeping the CSS sheet uncluttered and making it easier to update styles across a site. However, it seems that this risks cluttering the HTML document by assigning multiple classes to one element. Is this a problem, or does it not cause issues in practice because you generally shouldn't be assigning 15 classes to one element if you have a consistent style across your site?

1 Answer

Steven Parker
Steven Parker
231,236 Points

Assigning multiple classes to HTML elements is a common practice, but it should never become so excessive as to be considered "cluttered". Selector combining (such as descendant selectors) can also provide ways to categorize elements without giving each one another class.