The problem with CSS

July 2006

I don't think CSS isn't the right solution for layout.

The box model just isn't intuitive enough for normal human beings. Years of mathematical training have left me capable of handling that sort of thing, but it's still not the part of a project that I relish. Life isn't made any easier by various browser bugs but I suspect that they're a sign that it's not something that's natural to implement.

The thing is alignment is important to design and CSS doesn't do alignment well. Using CSS reminds me of trying to write something in C when Java would be more appropriate to what you're trying to do. It might be very powerful in the right hands and there are somethings where you need that power, but it making doing the most common things remarkably easy to mess up.

I'm as evangelical as anyone as separating presentation from content, but I also think it's possible to separate layout from styling of text etc. Layout should be a different file from everything else, and it should be easy to tell the layout just by looking at that file. I've got vague ideas about how you might do this, but when I started to write them down, I realised I'd end up having to write a whole spec if people weren't going to pick holes. I think how you do this is an important problem though. You've got three main problems you have to deal - how do you cope with browser resizing (and different resolutions of screen), how do you cope with people resizing fonts and how do you make something flexible at the same time as making the file small enough and easy enough for a web browser to turn into something on our screen. There's obviously the problem of how you get everybody to use your wonderful solution too. But I get over-optimistically that if a standard is obviously a good solution and easy enough to implement then people will implement it and use it.