CSS CSS Selectors Selectors - Beyond the Basics DRY CSS

Aakash Srivastav
seal-mask
.a{fill-rule:evenodd;}techdegree
Aakash Srivastav
Full Stack JavaScript Techdegree Student 11,617 Points

DRY

I am always confused when I should create a new class for an element. Isn't it bad for structure to have many classes? Is it affecting SEO somehow? Where can I read about it?

2 Answers

Jack Weldon
Jack Weldon
1,696 Points

So long as you're using semantic markup SEO doesn't matter to a great extent (Though it can help to label your classes to reflect the content). The only times that I'm aware of where you would not create a class for an element are: The element is relatively simple and doesn't need a class, or you already have a large number of classes that can be used instead of creating a new one - Both of these reflect on how you've written your code and how easy it is to read.

Just go to Facebook, Airbnb or other great sites and hit Ctrl + U;

You'll see the source code with many classes. Don't worry about using many classes for now!