There have been some interesting developments recently in the field of CSS pre-processors. CSS pre-processors work around the very limited syntax of CSS by allowing you to create your stylesheets using a more powerful, expressive syntax which then gets turned into plain CSS for consumption by all the main browsers. A couple of ones that I've come across are SASS and LESS. LESS is the one I've felt most comfortable with because it's simply an augmentation of the CSS which allows you to incrementally introduce its syntax into your stylesheets.
For example LESS supports variables:
...mixins, operations on colors and size, etc. Check out the lesscss.org homepage for more.
<link rel="stylesheet/less" href="stylesheets/main.less" type="text/css" />
I'm not sure I'm quite ready to take the plunge running it live, in-browser on sites just yet, although maybe I shouldn't be according to Dmitry Fadeyev:
Running on Windows
The command-line compiler lessc is targeted to *nix-based platforms and requires node.js
Browse the code and download from GitHub: https://github.com/duncansmart/less.js-windows and feel free to fork it and send me pull requests!
To use it, invoke lessc.wsf via cscript.exe like so:
cscript //nologo lessc.wsf input.less [output.css] [-compress]
I've also added a less.cmd shim which will simplify it to just:
lessc input.less [output.css] [-compress]
If you don't specify an output.css the result is written to standard output. The
-compress option minifies the output. I'll look into implementing the other command-line arguments supported by lessc in due course.
I've added a couple of test files, so you can see if it's working like so:
/* Variables */
/* Mixins */
I may look into hooking this into Visual Studio's T4 support so that the *.css files are generated as soon as you save the *.less files in Visual Studio. (UPDATE: See Phil Haack's T4CSS that does this, instead using the .NET port of LESS. Thanks to David De Sloovere for pointing this out.)
Mark Lagendijk has created a nice little Windows GUI for the script. Check it out at http://winless.org.