I've played with a lot of useful tools like HAML and LESS that gives CSS the capability of creating variables. I'm wondering why this feature wasn't included when CSS started. Is it too redundant or is not really necessary for some reason?
I think it's because CSS wasn't really perceived as a programming language. HTML doesn't have variables either. Variables are often only seen as really necessary if you're going to manipulate them after you create them.
Bert Bos written up his position in Why “variables” in CSS are harmful, the other side is nicely represented by CSS Variables Are The Future.
Bos' arguments range from weak to vacuous.
Cascading Style Sheets (CSS) is not a programming language. At first, CSS was developed as a means for creating a consistent approach to providing style information for web documents. This purpose has not changed since CSS1. It is used to describe the presentation semantics of a document for certain markup languages (HTML, XHTML, XML, etc.).
What is great is that it is possible to create variables! One approach would be to use a server side language such as PHP and create some 'dynamic CSS'. Now there are several ways of doing so and here are some sites about that...
I find it useful to use 'dynamic CSS'. Here are a few examples: you can allow users of a site to change certain aspects of it such as font-size, you can change the style of the site even more easily, you can offer different style themes for a site, etc. The possibilities are endless.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With