The Dopefly Tech Blog

<< The Dopefly Tech Blog Main page

Less CSS - how CSS should have been!

posted under category: Standards on July 25, 2009 at 1:00 am by MrNate

Has anyone else seen Less - Leaner CSS? Let me sum it up for you. It goes like this:


And you can take that one to the bank.

Seriously though, Less is an app built in Ruby that lets you write CSS in a reasonable fashion, which it will compile into unreasonable standard CSS.

And what is reasonable for CSS? Where is it that the W3C has failed us so terribly? Less' feature set says it all: variables, mixins, nested rules and operations. You'll probably have to see it to believe it, but once you see it, you'll get it. Go ahead, visit the Less CSS site, just the home page shows you everything.

My only problem with it is that it's Ruby. I don't have anything in particular against Ruby, I just don't want to install it or figure out how to use it to start coding with Less.

So where does that leave me?

1) Rewrite it in a language I like more
2) Suck it up, use Ruby
3) Recompile it with jRuby
4) Run it with HotRuby (translate into Javascript)

Until then, I guess I will just be dreaming about it.

Too old to comment!
On Jul 27, 2009 at 1:00 AM Matt Williams ( said:
Why not just make your css file a cfm file and do something like so?

<cfset brand_color = "#4D926F">
##header {
color: #brand_color#

h2 {
color: #brand_color#

On Feb 20, 2010 at 1:00 AM Roland Collins (rcollins at the ever famous said:
@Matt - one word: caching.

If you put your CSS in a cfm file, you also need to ensure that said file properly communicates caching directives to the browser.

On the easy end of the solution spectrum, this might just mean adding a few cfheaders to your cfm/css page to communicate "not modified" directives. If your css is truly dynamic, well then you've just eliminated one of the biggest benefits of css, which is that it gets cached by the browser.

On Feb 20, 2010 at 1:00 AM Barney Boisvert ( who would have preferred an address at said:
All your problems have already been solved:

Well, maybe not all of them, but you can at least run it automatically from you CFML app.
Too old to comment!