Tips and Tricks for Organizing Complex CSS

Garrett Dimon has written a good article, Architecting CSS for Digital Web Magazine which is well worth a read. Two points he made particularly struck home with me.

Alphabetize Your Attributes

One take-away that I found particularly useful was Garrett’s recommendation to keep your attributes organized by alphabetizing them.

I’ve never used a particular method for listing my attributes and this sounds like a very sensible guideline to follow. Avoiding disorganization when coding is always a good thing.

Avoid Over-using !important

His advice to avoid using !important as a crutch also struck a chord with me. I have to admit that I have been guilty (on occasion) of getting out of a CSS fix by slapping !important after the attribute in question.

He’s right that you should try and see if the problem is due to specificity, the cascade or inheritance before you resort to this option of last resort.

Your CSS will be cleaner and you will avoid future potential problems caused by using this fix.