css ethos

Soldato
Joined
5 Mar 2003
Posts
10,771
Location
Nottingham
Problem at work with differing opinions. I usually apply one or two specific classes to elements where as another worker applies many general classes, like floatleft, bold, red classes... They are so general its just like writing inline style. Are both ways valid and good?
 
While technically both methods are valid, it sounds like he's taking the idea of classes to the point of being silly and pointless.

Personally, I think that having more than 2-4 classes on an item is sloppy and there is no reason for it.
 
"Red" or "Right" isn't a class IMO, it's a property. I try to use things with meaning like, "sidebar", "sidebar-module" etc. Something so that if you read the name, you could guess at where it was on the page.
 
Classes should be named and used to style page elements, as said above, "Sidebar", "Sidebar-Links", "News-Item", "Featured-Item" etc.
 
One of the nice things about CSS is your seperating the data and the presentation and it sounds like your friend is doing short hand for putting it back in, go with the examples above.
 
Not just one of the nice things, but one of the main points of CSS! If you make design choices like bold and red in the HTML, then you're defeating that point.
 
Both ways are not valid and good. You are correct.

Should you redesign your site, to be say... right and green instead of left and red... it wouldn't make sense anymore. That's a maintainability flaw.
 
Back
Top Bottom