F
18

Can we talk about how bad beginners name CSS classes?

I was helping a friend debug his website last weekend and he had a class called "blue text" for a red heading. That is when it hit me that a LOT of new coders name things based on what they LOOK like instead of what they ARE. If you use a class like "left-align" and then later move that element to the center, your code makes NO sense anymore. Name your classes after the purpose of the element, like "product-title" or "nav-link" instead of "big-font" or "green-box". Has anyone else run into this naming mess when looking at beginner code?
4 comments

Log in to join the discussion

Log In
4 Comments
the_laura
the_laura21d agoMost Upvoted
Read a blog that called this "presentational versus semantic naming" and it made total sense.
5
scott.alex
scott.alex22d ago
Ngl I actually name mine by looks on purpose because it's faster.
4
thomasb41
thomasb4122d ago
Oof, I've seen way too many "red-button" classes that are now blue, drives me crazy.
-2
finley_smith
Stuck with utility classes like @the_laura suggested and it fixed everything.
4