Page Layout Tables

CSS, divs, and stacked tables for web pages

Page 1 of 6 1 Current23456

Of Divs and Tables

First it was a fad, then a bandwagon, and now an ideology to spread dogmatic rhetoric about the evils of tables. “Uses CSS, not tables” is an oft-seen passphrase, implying—nay, insisting—that the two are mutually exclusive. That is obviously incorrect, since tables may be, and indeed should be, completely CSS-controlled, and are easier to use and more reliable than multiple floated divs.

The main problem with table layouts is that wysiwyg HTML editors allowed users to create layouts by nesting a bunch of tables, which it also loaded with deprecated (and often proprietary) formatting attributes. As layouts became more complex, all that messy code became too difficult to maintain.

Then along came good support for CSS, and developers and designers threw out tables and started using other HTML tags, mostly divs and LI’s combined with the CSS float, to create table-less layouts. That brought another set of problems.

The main problem with using floated divs is called IE. Among its collection of rendering bugs are many related to its poor handling of floats. Every other modern browser gets them right (following standards), but IE, though a little better in recent versions, continues to break floats. Until they fix it, IE is the main reason to use layout tables. That goes against a popular ideology, but I see it as just being practical, and I refuse to play cat-and-mouse games with endless browser bugs.

This site is designed with a simple div layout (with only one floating), so I’m not against div layouts. Some of my other sites are designed with simple table layouts. In each case, it’s the layout that determines whether I’ll use divs or tables. Either way, they are used properly and not deeply nested. If the layout needs more than one float in close proximity, IE will misbehave, and that’s the time to use a proper table layout.

This article is not about which way is better, because both are useful for layouts in various circumstances, and both may be misused and poorly implemented. What’s actually better is using either or both correctly. However, some of the div-only folks raise a veil of technical objections that, in my opinion, just don’t quite add up:

Now let’s see how table layouts may be correctly used.

Continued...

Page 1 of 6 1 Current23456

— KV5R is disabled. Please help. —

Valid HTML 5 Valid CSS WCAG 1 conformance Handmade with Ultra Edit Studio Xara Xtreme