Skip to content

24 ways to impress your friends

Vote down?

Rupert

Whenever I see mentions of variables and functions in CSS, the use cases for them appear to be identical to a #define in C rather than a genuine variable or function. In other words, what CSS authors are asking for are macros, not variables or functions.

In that case, this problem has already been solved with LESS. You create your macros as a less file and then, just like in C, compile it into a format the browser understands.

This, to me, looks like the ideal implementation and is superior to integrating that functionality into CSS itself. Otherwise, we push the burden of compiling onto the server on each page request or, even worse, the browser itself. You might not think of it as compiling because it is handled for you, but that is what would happen.