3 ms·
You can't. You can try to reduce the horribleness of a CSS file, but the language simply doesn't provide the tools needed to do the one thing all programmers n
by mikeklaas 16y ago
You can't.
You can try to reduce the horribleness of a CSS file, but the language simply doesn't provide the tools needed to do the one thing all programmers need to manage complexity: abstract away the common part of two specific processes into a reusable component.
I'll never forgive the designers of CSS for not at least providing immutable constants, if not variables.
- brennen 16y agoThe more I think about it, the more certain I become that immutable constants (a good idea, IMO) are the furthest CSS could safely go down the rabbit hole before the entire enterprise would consume itself in spaghetti-code madness. Not that plenty about CSS doesn't beg for better abstractions, but turning it into a programming language is kind of a terrifying prospect. I've see too much of what enthusiastic amateurs can inflict with JavaScript.
- joshd 16y agoHave you looked into Sass and Less CSS? I haven't used them in production. They seem to achieve reuse in a CSS-like way.
- ZoFreX 16y agoYou can. So what if CSS doesn't have variables? We can add them. CSS is the format it has to reach the browser in, it's not the format we have to write in though. There are multiple projects out there for writing CSS at a higher level, which "compile" to CSS but let you use variables and things like that.
- tjogin 16y agoOf course you can. The same way we make HTML manageable; by pre-processing it. Sass, Less to name just the two most common options.