CSS for layout

As you probably have noticed, it seems that the CSS vs. Tables war has begun once again. Ron Garret started it with his CSS rant yesterday, and overnight Reddit and Hacker News got cluttered with posts on this issue. So, I figured I’d drop my two cents.

The key to managing complexity in a system is modularity, you should know. That’s why you keep those MySQL databases separate from the PHP code that generates the dynamic content in your site. That’s why you don’t just compile all of your webpages into a single C program that interfaces directly with incoming connections. That’s why you can go to the computer store and buy 2 GB of memory, instead of just a new computer with more RAM. So, separating content from presentation does make a lot of sense. As Abelson and Sussman say in Structure and Interpretation of Computer Programs, small changes in a specification correspond to small changes in the program, and if I suddenly decide I want to use a new background picture for each of the pages on my site, I don’t modify the (X)HTML of all of them, I just edit the CSS file they include.

So, we can clearly see separating content from presentation does make a lot of sense. The problem, I believe, is that CSS doesn’t do that quite fully. Ron Garret makes a great point in explaining this in a more detailed way, the order in which the sections of the page appear in the file alters the way they are displayed. We haven’t achieved to isolate layout and style into CSS only. Another point that is usually discussed is that CSS is hard to learn, but it’s also powerful, we can make great designs with CSS that would take a lot of work by nesting tables.

What makes these web issues difficult to handle is the abundance of technologies that are actually in use, and that we want to make our sites available to as much people as possible. As a result, we become very permissive with users of IE6, for example. Not only permissive, we also make a huge effort to work around the many flaws of that browser by employing hacky techniques. That makes our code much more complicated that it should be, maybe we have to use a Javascript feature to fix a CSS bug, and the utopic modularity of websites fall to pieces.

We will not be able to manage this problem in the near future. Not unless we start abandoning broken technologies in favor of new standards. If we start using CANVAS but only display it after we detect the browser through Javascript and we make sure it supports this element, otherwise we load a special JS file that enables us to use CANVAS through VML, or Flash, suddenly all the technologies are intertwined in a complicated manner, and we are not making any progress because we are greedy about the number of visits.

Maybe if we stop caring so much about our daily hits, and gently restrict our site to be viewed by standards-compliant browsers only, or just don’t try to support those that aren’t, we’ll start moving forward. That’s evolution: what’s willing to improve survives, what is stuck will not. It’s a natural phenomenon. Once we stop worrying about the past, we’ll be able to focus on the future, and work towards a better way to separate content from presentation.

Tags:

One Response to “CSS for layout”

  1. [...] “CSS for layout”: Suggests that the separation of content and presentation is a good thing, but CSS doesn’t fully allow for this. Inconsistent Web browser technology, especially Internet Explorer 6, makes Web development awkward, in general. [...]

Leave a Reply