Tame Your Unruly CSS Files
I find people generally fall in to two categories: people that have been writing HTML since pre-CSS days and believe CSS is a pox upon humanity, and people that started writing HTML post-CSS and find it to be the most wonderful thing since Dreamweaver.*
Like it or hate it, however, CSS is here to stay for a lot of good reasons. And if you’re like most people, you write your CSS as you’re making your site, and it gets to be a mess by the time you’re done.
I stumbled across a really good web site recently that will clean up and optimize your CSS for you. CleanCSS uses CSS Tidy, an open source project, to go through your CSS file (either via URL or pasted) and give you a cleaner, improved version out of the other end. It has a number of configurable optimization options, mainly to make it either smaller or more readable, but the default settings are a nice compromise of both.
I’d recommend this site as a good way to clean up your CSS before you toss it out into production. Note that this is a cleaner and optimizer, not a validator. To ensure you have valid CSS, use The W3C’s CSS Validator.
*Personally, although my HTML days pre-date CSS, I like CSS for most things. Sometimes, however, it makes me want to smash my keyboard over my head, particularly over weird layout issues. It recently gave me fits over the vertical sizing of some div tags. After reading all of the various hacks people have tried to get what I wanted to do to work across browsers, I ended up making a table in thirty seconds with half the code that did exactly what I wanted it to do. Sigh.