4 ms·
I agree that CSS can be frustrating - but I think it's a bit harsh to state CSS has failed when so many people are able to successfully use it to create a huge
by lwhi 16y ago
I agree that CSS can be frustrating - but I think it's a bit harsh to state CSS has failed when so many people are able to successfully use it to create a huge range of layouts.
People assume CSS should be easy and straightforward - but like most things, it takes a while to get to grips with.
--
I think there are maybe two main problems with CSS.
One, is that for a long time logic wasn't enough when it came to writing CSS markup. A large number of browser quirks meant that hacks and workarounds needed to be employed all the time. This is luckily changing .. modern browsers are thankfully much more coherent than their previous incarnations.
However, this perceived lack of logically coherence - and the need for arcane knowledge - is obviously infuriating to most people starting out ..
The solution has been to learn a handful of techniques - read a lot, and press on. While it's initially annoying, its not an insurmountable task.
--
The second is that CSS requires a lot of diligence on the part of the developer. There are good ways of writing code. I've found the 'cascading' part of CSS is quite often forgotten about - but well written mark-up can use this to greatly simplify the complexity of spaghetti code.
--
"Example: vertical centering in CSS is far harder than it should be [1]. Why doesn't "vertical-align: middle" just work for divs like it does for table cells? I'm sure there are reasons. They just aren't good reasons. What's more: why hasn't CSS3 fixed this? It's a longstanding problem."
I agree - this is annoying.
However, HTML was designed to allow content to be viewed at various sizes - and to scale width-wise (allowing the vertical height to adapt automatically) - I've a feeling this might be part of the reason why vertical align hasn't been included). Vertically centring fixed height elements is very straightforward .. vertically alignment for dynamic height elements is less straightforward, but it's usually possible.
--
"My other big problem with CSS is the "inheritance" model. For one, it shouldn't be called inheritance. It should be called "cascading" because that's what it is."
The first C in CSS is there for a reason ;) I think the cascading feature is actually quite powerful.
One of the things I'd most like is a way to use variables in CSS - but this will thankfully be addressed in CSS3.
--
"Inheritance at the class level would actually be useful (and is another glaring omission)".
Classes can be combined, and once applied, a class affects the descending elements contained in the DOM. I'm not sure what you'd ideally like?
--
Lastly there are some good projects out there that address quite a few of the gaps in the CSS specifications in a very reasonable way. LESS[1] and SASS[2] are two that come to mind.
[1] http://lesscss.org/ http://lesscss.org/
[2] http://sass-lang.com/ http://sass-lang.com/
- ericb 16y ago[3] http://en.wikipedia.org/wiki/Stockholm_syndrome http://en.wikipedia.org/wiki/Stockholm_syndrome
- lwhi 16y agoBut I honestly believe sometimes a bad workman blames his tools. I took the time to learn how to use it, so maybe I'm biased - but it's really not that bad.
- Travis 16y agoAnd sometimes tools are just bad. Yes, a bad workman blames his tools, but that doesn't mean all tools are as good as they can be. Sometimes a good workman blames his bad tools; when there aren't better alternatives, what can he do? Let me put my CSS thoughts in context: I self-assess to be about as competent in CSS as I am in PHP. Now, I know PHP isn't great. But when I'm smash-my-head-against-the-wall frustrated, it's usually because of CSS issues. >75% of the time. In general, I expect frontend layout work to be less frustrating than backend work. It's less complex, IMO. And, actually, it can be -- just by using tables for layouts. So it's not inherent complexity that causes the frustration, it's the CSS issue (tables remove that frustration for me). In short, I've returned to table based layouts because that tool fits my needs much much better than CSS. I use CSS for my styling, but layout goes into tables.
- lwhi 16y agoMaybe you should concentrate on back-end development? I can sympathise, but I really don't think reverting to table-based layouts is a good solution. EDIT: Reverting to table-based layouts _ISN'T_ a good solution.
- Travis 16y agolwhi - sure, I'm more comfortable doing back end dev work (and try to focus on it). But that doesn't change my opinion that CSS is a half assed solution that doesn't solve my problems. Tables do. And the counter-arguments against using a table based structure all tap into situations that haven't affected my specific context. So tell me again why I should use CSS based layouts? For me, they frustrate me and prohibit me from accomplishing my tasks. Tables don't do this. And all the downside to using tables? Not particularly relevant for my goals.