Class Names Organisation

User 2660090 Photo


Registered User
89 posts

I'm wondering what policy you guys have in place with CSS class names. I think when you start off using RSD, it's quite tempting to literally create a new class name for every new element you have. But obviously doing this creates havoc over time, as there is no structure to what you are doing.

At the moment, I have an okay approach, I think. Because my designs are pretty consistent, I can reuse classes quite often. But the key thing is how specific should you be with classes? If I change only the colour of a font for one my rows — and that's the only change, should I use a separate class just for the font colour? If I have a class that only covers white text, for example (on a black background), I could then reuse this class on other rows where I need it.

So to summarise, should I create separate reusable classes for things like the font, or should I include this styling all in one class that includes other alterations, too.
User 187934 Photo


Senior Advisor
20,271 posts

Hi Andrew,
I don't think there's really any hard rules. As your seeing there's a lot of flexibility using classes. You may only use the class once on a page but because you used a class you can use it again later on the same page.
I try to limit mine to some extent to keep the style sheet size down but I don't let myself worry if I need another class as a style sheet size isn't going to increase that much and you could better your page load speed by working on images first.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.