Live data from Hacker News

Why "variables" in CSS are harmful

w3.org

1–10 of 13 posts

Re: Why "variables" in CSS are harmful

#6
He used reusability as an argument.

So having to retain the same values 100 different places in the stylesheet(s) makes them more reusable and maintainable than having the ability to define constants once?

What a joke.

Re: Why "variables" in CSS are harmful

#7
The point that this can be done as a separate, server side processing phase has merit. Too bad it had to be wrapped in a ridiculously long, patronising article, containing such gems as the observation that style-sheets are rarely longer than a hundred lines. Right. And I'm not even going to comment on the choice of background.

Re: Why "variables" in CSS are harmful

#8
post #7

The point that this can be done as a separate, server side processing phase has merit. Too bad it had to be wrapped in a ridiculously long, patronising article, containing such gems as the observation that style-sheets are rarely longer than a hundred lines. Right. And I'm not even going to comment on the choice of background.

Sometimes it can be done on the client side too.

It's called XSLT.

Re: Why "variables" in CSS are harmful

#9
post #7

The point that this can be done as a separate, server side processing phase has merit. Too bad it had to be wrapped in a ridiculously long, patronising article, containing such gems as the observation that style-sheets are rarely longer than a hundred lines. Right. And I'm not even going to comment on the choice of background.

I feel the server side thing is not a good argument, after all, there is not always a server side. HTML documents can be distributed standalone.

Also, it is much harder to do CGI scripting than to deal with possible constants in CSS.

Re: Why "variables" in CSS are harmful

#10
post #6

He used reusability as an argument. So having to retain the same values 100 different places in the stylesheet(s) makes them more reusable and maintainable than having the ability to define constants once ? What a joke.

If you're using the same values in 100 different places in a stylesheet you're frankly using them wrong. There's actually a decent point there - adding variables will undoubtedly encourage that sort of thinking and create further constant abuse rather than encouraging people to use the cascade and inheritance.

That said, I'm not sure if that potential problem alone justifies its lack of introduction - there are legitimate use cases as well where they will improve clarity, the ability to provide complex CSS as boilerplate and get people to change the constants to suit their needs would be useful (e.g. easy recycling of complex column code) and I think their argument about code reuse is pretty much nonsense too.

Post reply on HN