Tables My Ass
Friday 14 May, 2004 (10:47AM GMT)
High profile CSS advocates have been abducted and replaced by beings extolling the virtues of table layouts. Much like talking to Donald Sutherland at the end of Invasion of the Body Snatchers, we find ourselves whimpering "Andy...? Andy...? You still love CSS... right?".
Partly in response to David Emberton's ridiculous anti-web standards drivel, these "devil's advocate" objective critiques of tables for layout (kicked off by Andy Budd and then Dave Shea) unfortunately fall short of the mark and don't convince me in the slightest. So here's my response to their response and my turn at objectivity, which looks a little different. Objectivity doesn't mean sitting on the fence and I objectively conclude with pride and confidence that there is little or no room for tables in layout.
One myth is that CSS is 'hard'. It isn't hard. Well, not any more difficult than any other approach. The problem is that experienced web designers started out by using tables for layout and then had to completely change their approach to do things the CSS way.
I worked with tables based layout for years and when I first started playing with CSS layout I got stumped. "It was so much easier with tables" I thought. But that just came from the fact that I was comfortable with tables. I knew how to manipulate them. Any change, especially such a radical one, is inevitably going to prove difficult. But I even remember when I first taught myself how to use tables for layout. That confused the hell out of me too. Looking back on it, I would even have to say that table layouts were the more difficult of the two approaches to learn, what with all of those rowspans, colspans and spacer gifs.
Another odd point that Andy Budd raises is that a CSS designed page can be just as heavy, if not heavier than a page with tables. His reasoning is that because you have all of the site styles in one file and that needs to be downloaded first (which will usually be when the user visits the home page), this CSS file could actually be quite big (containing much more than the styles needed for the homepage) and so the design is top-heavy. But if it were the case that the CSS file became so large that it impeded download time in this manner, why are all of those styles in one file? You aren't limited to one CSS file and you shouldn't use one CSS file if there are substantial parts of it suitable only for particular sections. In my experience, from developing pages for small brochure type sites through to vast database driven, multi-section systems I have never come across a single case where the entire homepage (that's including the necessary CSS file) is heavier than a table-based equivalent. Those
td tags take up a LOT of space and in practice a CSS layout slashes file sizes.
Forgetting semantics (because that's essentially what you are doing when you're laying out a page with tables), web standards layout still has the massive benefit of separating content and presentation. A table will lock you into a design. If you need to change it, you need to go into a page and fiddle with the table structure ("right... so... that cell spans three rows and this cell spans five, which is next to another cell that... oh damn it! What the hell is going on?!"). No simple global changes through a CSS file (which also have the added bonus of increasing the likelihood of visual consistency across the site). And you can forget about device independence. And forget about those who choose to use their own stylesheets.
I see few benefits for tables. Laying out forms. But then forms can be seen as tabular anyway, so it's sound. Netscape 4? I'm not even convinced that supporting such old browsers is a reason. The benefits to the vast majority who have more capable browsers will far outweigh the disadvantages to the tiny minority who will see unstyled yet fully functional content. These pro-table (yes, I know they're only "devil's advocate") arguments seem to boil down to "it's easier", which is tosh. If you want to stay with the comfort of an inefficient hack methodology, that's up to you. But if you want to push things to their limits and make the most versatile, accessible, lightweight pages possible, make the effort to switch. If you had used it from the outset then you wouldn't have this problem. I've had plenty of positive feedback from HTML Dog readers who have managed to layout pages without even considering tables.
"If it aint broke, don't fix it", "it's a tool in the web designers toolbox" are some of the comments that have come up. Table layouts are a battered old soft-metal screwdriver with a rough wooden handle. You can still screw screws into a wall with it, it's just that I prefer to use my badass sturdy electric screwdriver instead. The screws are straighter and my hands are blister-free.