Why "variables" in CSS are harmful. Bert Bos thinks constants or macros in CSS will make it harder to learn. I personally think that the problem with CSS isn’t the learning curve, it’s how difficult it is to maintain later—and I see macros as a great way of reducing that maintainability burden.
I’m with you. I don’t understand the apparent emphasis on keeping things easy for the “learn from view source” crowd. At some point when you’re learning CSS, you need to buy a damn book and actually learn it.
I'd say that as long as there's an unambiguous way to tell that a certain token is a variable/constant, then I don't think it will actually be that much harder to learn. At the very least, CSS newbies can take the feature or leave it. While view-source is a good learning tool, it shouldn't be the *only* resource for someone learning CSS.
Nathaniel - 6th August 2008 03:33 - #
I'm not a big fan of the CSS variables idea. Semantic variable names don't play very well with the idea of reusability, and meta-description of values tend to become a bit too philosophical for my taste.
Leo Horie - 6th August 2008 05:56 - #
Firstly, I wish people would stop calling CSS Constants "Variables", this will only cause confusion.
Secondly, CSS doesn't need to be "simple" - it needs to do the job of effecting presentation well. So far it's been simple because it's not done a very flexible or particularly good job of that. Ease of learning is irrelevant to the function of a language.
Matt Wilcox - 6th August 2008 13:21 - #
well. One could use CSS without these "constants", and still produce effective stylesheets. If someone stumbles upon a constant in a CSS, he/she could search a bit for more documentation about it, and then learn something about it.
CSS as it is now is sometimes hard to understand... Why do we need "color" to define text color, and "text-align" to define text alignment, and font-size to define text size? Why not having text-color, text-alignment and text-size?
CSS, as any other computer-related language (I didn't say "programming language") needs to be learnt, because it's not a natural language. Accept it.
And constants won't change this. We'll still see people unable to hack on CSS and others who'll dig it.
No' - 6th August 2008 13:40 - #
Actually, The whole (and single) point Bert Bos makes is moot when you consider that all modern browsers can return the computated style of an arbitrary element. (firebug, dragonfly, IE devtoolbar, safari's web content debuggin tool)
You would think a css working group member would be familiar with that.
Kilian Valkhof - 6th August 2008 14:00 - #
I don't have the compsci brain to look into it all the way, but: either the introduction of new CSS functionality conforms to its existing status as a more-or-less functional typography language, in which case: whatever; or it turns it into a non-functional typography language, in which case: it's probably broken it in some nasty way that might not be immediately obvious.
At first sight, it seems fairly of a piece with the functionally consistent variable assignment I know from XSLT. Can you redefine them, once defined?
If you think about it, css already has constants (in a very limited fashion).
You can use 'red' or 'lightblue' as color names.
Matthew Nuzum - 6th August 2008 17:37 - #
Yes, giving a name to a hex color code that is used a few dozen times would be very helpful to make stylesheets more easy to configure for different purposes. Most designs only use a handful of different colors but use them in a lot of places. CSS definitely has verbosity issues.
The way CSS currently works actually stimulates copy paste reuse on a massive scale. Anybody who knows anything about software development knows the problems associated with that and the web is indeed full of broken designs with css fragments pasted together.
Anyway, the point is moot because we'll be supporting old browsers that don't support this for years to come so any kind of css changes like this won't be of use until most browsers understand them.
It would be nice in general if the W3C wakes up from their decade+ period of hibernation regarding CSS. The language is still surprisingly difficult to use for some very common design issues that are either not possible at all or require lots of work to get working at all.
All they've done lately is move commas around in the existing CSS specs. CSS 3 has been coming as long as I've been using CSS which is pretty much all of this century so far.
Jilles Van Gurp - 6th August 2008 18:33 - #
I wish he gave an example of what the hell he's talking about. The things he describes sound completely different from what I thought.
Maybe I don't really know what a "macro" is but I don't see how anyone would be confused by this:
http://www.webmonkey.com/blog/WebKit_Experiments_w ith_CSS_Variables
Again, I'm not sure what the hell he's on about but in my opinion css variables would not make stylesheets any longer. They would make them the exact same length + the definitions of a handful of site-wide colors and fonts which reduces the time it takes to make sweeping changes to a site's appearance.
queefsnoggle - 15th August 2008 19:30 - #
Does this guy even do web design 9-5 5 days a week?
xxx - 15th August 2008 19:36 - #