CSS vs. Nested Tables

Cascading style sheets weren’t always an option for designing your web site. When the Internet first began to transition from the world of academia into a commercially viable tool, not much thought had been put into how information would be displayed. Creative designers recognized, though, they could make use of the limited markup options available to dramatically effect how the information on a web page was displayed.

Although tables were originally intended to display tabular data, creating a table with a border width of zero pixels allows you to position text and images in a controllable space. By nesting tables inside each other and specifying the alignment, padding, and other properties of a table cell, there’s almost no limit to how you can contain and position the information on a website.

What’s Wrong With Tables

The ability to control how information is presented via tables comes with a cost, though. The resulting HTML files get very large. They can take a very long time to download. Maybe your site comes up almost instantaneously over a broadband connection. What about over a dial-up connection? Maybe in suburban America the modem is quickly becoming a technological relic, but there are quite a few Internet users in other parts of the world who take their web through a 56 kb/sec tube. These are people who read and speak English; they are a potential market, and their numbers are growing every day.

We don’t have to look that far from home, though, to see file size becoming a real factor. I can look at web pages on my cell phone for the bargain price of one cent per kilobyte. At least that rate is a bargain if your average page is 2.5 kilobytes. I’m happy to navigate through several pages of your site. If you use nested tables, and the smallest page on your site is 35 kilobytes, I’m only going to check one or two pages before I head elsewhere.

Speaking of losing potential customers, how is your site presented to someone with a vision disability? When a blind person comes to your website and listens to their computer reading the content of your web page, what do they hear? If you use nested tables, they’ll probably hear bits and pieces of useful content broken up by trivial (but very detailed) descriptions of where blocks of information are positioned in relation to each other.

And what about the most forgotten visitors to your website? What do nested tables mean to the poor search engine “bots” that come to your site? Search engines want to provide relevant search results to the masses, and they are desperately hoping that your site will fit the bill. All they need to do is look at your content and determine what your page is about. Unfortunately, with nested tables your page is probably more presentational markup than actual content. Search engines know that the text inside an <h1> tag is very relevant to what your page is about. How important is:

 
<table border=”1” cellpadding=”3” cellspacing=”1” width=”100%”>
  <tr>
    <td align=”center” valign=”top”>
      <b>
        <font face=”Arial, Helvetica, sans serif” size=”+2”>
          What My Page Is Really About
        </font>
      </b>
    </td>
  </tr>
</table>
 

What’s Right With Tables

If tables create such problems, why do we even have them? Tables can be extremely useful for displaying certain types of information. Think about sites that let you compare the features of similar items. Let’s use hosting plans as an example. Each column represents a different hosting plan. Each row represents a different feature like storage capacity or monthly bandwidth. Including things in a table makes it very easy compare and contrast the information.

As much as it pains the purists of CSS standards to admit, there are even some layout challenges that are easier to solve with tables. The common layout of two different colored columns is almost comically simple to create with a single-row, two-cell table. It will look the same in every major browser. You can achieve the same effect with CSS, but it requires writing some extra code and jumping through a few hoops. Once you become familiar with style sheets, though, they are generally easier to use for layout than tables.

How Layout Should Be Handled

So what’s the “best practice” way to handle page layout? I suggest starting by writing the content of the page with just basic HTML. The title of the page should be in an <h1> tag. Subtitles should be in an <h2> tag. If the page is going to have a navigation bar, put those links in a <ul> tag. Don’t worry about how you want them to be displayed on the final page. We’ll get to that soon. Include the site logo and any other distinct images, but don’t worry about backgrounds. The goal is to completely separate content from presentational markup, so you shouldn’t be centering anything or changing borders.

Once you get all of the content on the page, you’ll have a pretty good idea of the order and emphasis that will be seen by search engines and text readers. Does it make sense? Make any changes before moving on.

Add a line like this within the <head> tag of your document:

<link rel=”stylesheet” type=”text/css” href=”mystyle.css”>

The mystyle.css file is the place to change how this page looks. Here you introduce color, size, positioning, and typography to implement the actual “design” of the page. You may find that you need to add extra <div> tags here and there in order to bring your design to the page. Go ahead. Sure it would be great to have a web site that didn’t need any “invisible” tags to effect the presentation, but it never seems to be very realistic. It’s still better than the lines upon lines of code you had with nested tables.

  1. Joe  • 

    Tables are easier to use but the size reduction with css makes a big difference.

  2. Clay  • 

    Ha! Joe, I could’ve saved a lot of time writing this post if I’d just consulted you first. Much more succinct.

  3. Peter  • 

    That is the most coherent nonreligious article about css-p I have ever read.
    I am pro css, but I am not a css freak, if my client wants a site which has only 5 pages and actually wants to maintain it him/herself. Tables+ some css is the way to go. I am not in the habit of wasting my time or my clients money. Most search engines don’t really care about table tags, they simply ignore them, and relevancy is calculated through statistics, not by how far the search word is from the top of the document or weather or not it it is enclosed in an tag. The smarter search engines ignore tags altogether. In the future, the search engines are only going to get smarter, to countermeasure those who try to climb to the top with clever design, but irrelevant content. Although I will be the first to admit that css+divs is the wave of the future, and div positioning and graceful degradation are a beautiful thing. Sometimes they are just not worth it.

  4. Clay  • 

    @Peter: that’s a great point. Search engines are very sophisticated. Everyday I uses Google and end up finding pages that use nested tables for their layout. The content of the page is good, so it makes it into the index. Since writing this post a year and a half ago, I think I’ve finally come up with way to treat SEO that works for me. Anything we can do as designers to make it easy on the search engines is great, but ultimately they are going to create algorithms that place pages with good, useful content at the top of their results regardless of the mark up.

Leave a Reply