Developing a design with a css layout or a table layout are the two predominate ways to build a website. Those of you who know me know I lean heavily on the side of css layouts, but there are still many who believe that a table layout is the better option. Recently I came across an article written by one such person. There so many inaccuracies in that article that I want to discuss it here.
The article in question CSS And Tables: The Hype And The Trends by Deepak Sharma stuck a chord in me as backwards thinking and full of misleading opinions. Even though I had written not long ago on The Benefits Of CSS this article made me want to take up the argument again if only to clear up some misconceptions put forth there.
The History Of Tables And The Reality Of CSS
I agree that whoever first used a table to layout a website should be applauded. True the use of tables as a layout tool was a hack of html and I will admit that I have often unfairly used this fact as an argument against their use. While the language was never originally intended to be used this way many great technologies came about by putting something familiar to use in a different way and it is true that using tables expanded the design of websites and the popularity of the web. However today the situation is reversed in that tables confine the way a website can be designed and css is the expansive technology. Tables by their nature force everything into a box. CSS while also boxlike does let you break the boundaries of that box and move outside of it.
Mr. Sharma argues that using tables to layout a website is the pragmatic approach to web development and that it is difficult to implement css to layout a site. This couldn’t be further from the truth. It is just as quick and easy to build a site using css as it is with tables. For me it’s easier and quicker to use a css layout. His argument seems to stem from the use of WYSIWYG editors and I would say take the time to learn the code those editors are producing. If you do you’ll be hand coding pages faster than it takes to create a site with a WYSIWYG and then debug the code the WYSIWYG produces.
A CSS layout is far easier to maintain than a table layout. Changes generally need to be made to one external css file to update an entire site. The same can not be said for tables. Changes to the design of a table based layout will need to be made on every page of the site. If you don’t think you’ll ever change your site think again. What happens when you decide you want to add something new in your sidebar. With css the addition is trivial, with tables your new block of rss feeds is not likely to make it into your site. To change a table layout you will need to change the entire structure of the page and the site. If you don’t believe how easy it is to alter the entire look of your site with a css layout visit the css Zen Garden site and see how much can be done by editing a single file.
It may also be true that the majority of websites are still developed using tables, but that is not because tables are a better option. It was also true at one time that more people traveled by horse and buggy than by automobile and that most people saw no need to switch over. That didn’t make it the better option. I’m amazed that someone who works in a field that is all about technology could even use as an argument that since browsers are still willing to clean up the mess of poor code that there’s no compelling reason to write good code.
The reality is that far too many developers are unwilling to spend the time it takes to learn css. Sad since it’s not really any more difficult to learn then html. Much easier than most seem to think. Most of the people I see struggling simply haven’t taken the time to understand a few of basic concepts before jumping in. I’d recommend any book by Eric Meyer as a way to give you a good grounding.
The Ease Of CSS Layouts
CSS development does not present a higher barrier to entry than table based layouts. Most of the difficulties I see people having with css layouts has more to do with trying to make them act like tables and fit into pre-existing table based layouts than because the css concepts are difficult to assimilate. CSS layouts are different, not harder.
There are not a lot of ‘bugs’ as Mr. Sharma seems to think. Perhaps that was true in older browsers, but version 5 browsers have always been more than capable of handling a css layout and since those version 5 browsers are about 8 years old now why would you be developing for anything prior to them on most sites? Today’s browsers have very few ‘bugs’ and quite honestly it’s very easy to account for them. In developing I code to the standards and in the end add about 6 lines of code for Internet Explorer. I’d suggest the ‘bugs’ are more in the knowledge and skill of the developer than in the code or the browsers.
I have never had to write fairly complicated css to do something that would be trivial with tables. If anything the structure of a table is the fairly complicated code. CSS layouts are much cleaner in their structure and in their presentation. If you’re writing complicated css then you simply haven’t learned to use css It’s not any more involved than nesting tables inside of tables inside of tables. It doesn’t take a guru to layout a css site. It just takes someone who has made the attempt to understand how css positioning works. Most of the time the css used for an entire site will have less weight than the html of any given page. And only a small amount of the entire css file will be used in the layout of the site. Most will be for stying the various html elements.
I’ll admit I may still use a table to layout a form or two. There are uses for tables. I’m not arguing they should never be used, but only where appropriate. The overall layout of your site is not the appropriate place anymore. Mr. Sharma seems to think footers are difficult with css. Take a look at either my 2 Columns CSS Layout or 3 Columns CSS Layout posts to see how easy it is to have a footer in a css layout. There are even other ways to add a footer to a css layout that are just as easy.
CSS Layouts For Faster Loading
CSS sites will load faster in a browser. There is no question. Part of the concept of moving the css code to an external file is so that a browser only needs to grab that code once and then refer to it from it’s cache. Much faster than having to get all the code every time a new page is requested. And the only time those external files are complicated is when the person creating them isn’t fully understanding how to use css. That’s not the fault of the technology.
Browsers need to read all the code of a table before they can display it on a monitor. Once to understand the structure of the table and a second time to present the information in the table. While the browser is doing that visitors to your site see nothing. They get the whole table at once. A css layout can be presented as the browsers encounters the code. Your visitors can begin to scan your content while they are waiting for your images to load. And since you have such a short time to capture their attention why make them wait.
CSS, SEO And Accessibility
The jury is still out on the benefits of css when it comes to optimizing a site for search engines. It’s likely that the less code used in css will help in some way though again the jury is still deciding. Search engine spiders have become pretty good at reading poor code due to necessity. I do think leaner code means spiders and robots can get through your site faster and if I’m not mistaken the latest version of Googlebot uses the same engine as Firefox to navigate your code. If css and standards are easier on the browser it only stands to reason that it will be on the spider and robot too.
There are some that believe that being able to present the structure of your html with your keywords at the top of the page as css allows you to do will provide great seo benefits. I’m not convinced of this, but it’s possible that it will have some effect. Search engine optimization is about so many things taken in unison that it’s difficult to measure the effect of many of them individually and while it’s possible that css may provide some seo benefits it’s certainly not a panacea as Mr. Sharma says.
I’ll completely agree with Mr. Sharma about accessibility. A table based layout can be just as accessible as a css layout, though the css layout is probably still the better approach if you want to develop an accessible site. Mr. Sharma himself even points out that css layouts are the recommended approach. If the organizations that are determining what is and isn’t accessible are recommending css layouts wouldn’t it make more sense to use css if you want an accessible site?
If you read through Mr. Sharma’s article many of his arguments acknowledge that a css layout is often better than a table layout. He then typically backpedals by saying that they’re not really that much better so they don’t need to be used. Yes many developers still use tables to layout a site, mostly because they haven’t taken the time to learn how to use css properly and efficiently. The number of developers using css layouts though is growing all the time. Table layouts were a great hack in using html to present a web design. That was a good thing, a very good thing. Table layouts created a better way to present a web page and helped just as much as anything in the explosive popularity growth of the web. There now exists a better way to present a web design. CSS layouts are an improvement on table layouts much the same way that table layouts were an improvement on what came before.
Download a free sample from my book, Design Fundamentals.
Hi π
I am not taking sides; I am presenting another opinion, and not my own.
http://www.accidentalscientist.com/2007/07/css-sucks-for-layout.html
Your layout broke on text enlargement in several popular browsers. The fact remains that design structure easy to tables is impossible with CSS.
In the two decades that CSS has been available for use, one might expect that design and structure should be better implemented.
When I received my degree in Computer Science – Programming, table based design was not an anomaly, it was the standard. CSS was used for Typography and Style site-wide.
Regards π
Sorry Art, but I beg to differ.
First a question. Can you tell me which popular browsers have trouble with this layout when the text is enlarged? It seems to work fine on every browser I check. If I did miss something please let me know so I can fix it.
There is nothing that you can do with tables that can’t be done with css. So far 100% of the time I’ve heard someone argue that something can’t be done in css it’s because the person hasn’t taken the time to learn css.
CSS is so much easier to develop with and so much easier to maintain. I have a hard time understanding why anyone would still use tables for site layout.
By the way the site you link to arguing in favor of tables uses exactly 0 tables for it’s layout. It’s an all css layout. Yes I do realize it’s a Blogger blog, but I would think someone who argues that css isn’t good for layouts would look for a blogging platform that doesn’t use css.
You might also want to check your dates. The CSS 1.0 spec is from 1996 and it was a few years after when browsers became fully compliant with the spec. That means it’s been closer to 10 years or one decade and not two.
That was then, this is now. Do you advocate always going back to the way things were? Should we go back to bloodletting and leeches as a cure for most all ailments too? They were the standard too at one point.
Very helpful. So much for all those old siteS I built using Dreamweaver in Design mode!
Hey Steven;
A couple of notes:
1. OMG, I’m using Blogger with CSS!
Yep. I’m using Blogger – or I was. I recently finally sorted out my hosting issues and put up a Wordpress site. Regardless, Blogger’s a matter of expediency – and I’m not religious about this stuff. I use whatever works. And to use Blogger, you use CSS.
Whether it’s fit for purpose is another matter. It’s like the choice between aspirin and tamiflu. Both will alleviate symptoms. Tamiflu makes your flu go away faster; the aspirin just hides the pain for a little while.
2. As for nothing you can do with tables that you can’t do with CSS? That’s a pretty lame argument. There’s nothing that you can do with a computer that you can’t do with pencil and paper. Heck, I could do my layout entirely with absolutely positioned images of each character in the alphabet – that doesn’t mean it’s the best, easiest, or least error-prone way.
I’ve built a few websites… http://frogchildren.com is one. A few others went offline as companies changed directions, and I’ve been doing this on and off since 1994. Still doesn’t change that CSS is arcane, when it should be simple.
Thanks for dropping by Simon. A couple years later, but still thanks for the reply. π
1. I have no problem with you using Blogger, however I do have to ask if you felt css was so bad at layouts why would you choose a system that uses css? Wouldn’t you want to develop layouts with tables if you think they’re better than css?
2. I’m not arguing that you should use css because you can do anything with css that you can do with tables. I’m saying it in reaction to the argument that you can’t use css, because it can’t do everything that tables do.
The lame part is suggesting that css can’t do what tables do, since it’s not true. I’m simply pointing out that untruth.
I’m not sure if you’re interested in carrying the debate further, but I have a more recent post on the subject, CSS vs Tables: The Debate That Wonβt Die on the subject, which I think is a better post than this one, It’s a few years old, but it is 3 1/2 years more recent than this post.
I learn CSS (your blog helps a lot) and I too had a “tables phase”. When trying to produce some layout, I many times tried some css positioning, then some floating, then when everything failed, went back to those “good” old tables. I was aware those failures were entierly due to my lack of understanding of CSS.
I find conforting to see that, in a time not so far away, there were people defending the use of tables against CSS, and finding CSS “arcane” – a feeling I had so many times. I feel a bit less dumb.
But I remain with this question : when should tables be used? I have come to believe they could and should always be avoided, even when building grids. And indeed, it seems the website of my bank shows statements in a grid only made of divs.
So, is there still any use to tables?