How do you keep your stylesheets clean and relevant?


I always end up with messy stylesheets.

  1. My main problem atm is to remove from the stylsheet declarations that don’t have any reason to exist (= the relevant html couterpart has disappeared from the html file). Is there a program that crawls your pages, and see if you have css declarations that are used nowhere?

  2. How do you organize your file (@import or one file)?

  3. When stylesheets get huge or disseminated into multiple files, how do you make sure that there isn’t two declarations contradicting each other (so far, I’ve used firebug to go through my html tags and check the css code)?


-jj. :slight_smile:

One tool I’ve used is DustMe Selectors (which is made by SitePoint :smiley: ).

For the rest, I’d say it’s as much to do with good planning as anything else. Decide on a layout, then organize styles as seems logical to you. Generally I prefer one style sheet, unless it’s getting very long, in which case I separate out things that apply to one or two pages only. I’ve never taken to @import, but maybe that’s just me.

DustMe just seems like a great tool!

More advice are welcome.