Hating <table>s considered harmful
Apologies to Dijkstra for butchering that quote again , but the rage against <table>s is getting out of hand. Back in the dark ages, when it was impossible to get consistent HTML rendering across browsers and platforms someone decided to use the <table> element , originally designed to markup tabular data, to layout webpages.
Ever since that moment <table>s have been an unfairly shunned part of the HTML spec. When CSS became a stable and supported spec many people started screaming from the roof tops “Stop using <table> it ruins webpages”, and too many people have taken this to heart, so much that any time tabular data needs to be presented bizarre alternatives are used.
This was an example of a bad table of data that caught my eye a while ago:
Its supposed to give an idea of the cumulative revenue of iPhone Apps over time, but its hard to tell that as there is no title. Good data tells a story, good metadata explains that story. There is no metadata here to explain any of these numbers, here is what a search engine sees when they look at the HTML on that page:
Period ending.....Period downloads.....Cumulative downloads....Period revenues Jun 2008............no apps...................no apps........................no revenues Dec 2008.............600 M......................600 M..........................$ 172 M Jun 2009..............800 M....................1.4 B.............................$ 228 M Dec 2009..........1.6 B.........................3.0 B............................$ 458 M Jun 2010...........2.0 B.........................5.0 B............................$ 542 M Total.................5.0 B.........................5.0 B............................$1.4 B
Accessibility and search robots aside, here is no context to any of this, the units change between rows, the number of dots changes each time. Its hard to say what this data is without purposefully reading the text around it. I could drone on about the lack of metadata describing the data in this table, but instead I’ll counter this with a better example.
Here is the same table, rewritten as an actual <table>, using only what’s defined in the HTML4 and above W3C specifications:
A few things instantly stand out: the columns all match up nicely, both in display and in the table-model; each of the years is clearly marked; the table is relatively self-explanatory; and lastly it appears as a table to anyone who reads it. Furthermore, all of the formatting is done using CSS; thats right the presentation is left to the CSS and the descriptive markup is done using a <table>, just how it is intended to be done. But even this is only a fraction of the possible metadata to place into a HTML table.
However, this is not the worse example of a ‘table’ I have seen, the one that sent me over the edge was this large image that highlights the relative pros and cons of different smart phones:
The main issue with this, is this image of a table is mostly text, is quite large and static. You cannot easily copy text out of this, you can’t easily reorder the table and unless you have a large screen it would be quite difficult to compare two products that weren’t both very close to each other. Unlike the table of iPhone revenues, I am not going to go to the effort of transcribing this into a proper HTML table.
Compare this with a similar table from wikipedia also providing a comparison of smartphones and the differences are obvious. First of all, the table is now web-crawlable – whatever data is in this table is now indexed in Google, instant bonus, and the user can easily search through the page to find what they needed to know. There is also a whole lot of Javascript on the page. For example, clicking the boxes next the each of the column titles reorders the whole table around that column. In the first table this isn’t too noticeable with most entries having either ‘Yes’ or ‘No’, but the Hardware and OS table from further down the same page is full of figures, and now I can easily find the lightest phone (it’s the HP iPAQ Voice Messenger, something that would be much harder to find out on the image ‘table’).


When was it ever implied to never EVER use tables for ANYTHING?! Unless there are loads of misguided n00bs out there taking the no-tables-no-tables-no-tables mantra at face value, I’m pretty sure that anyone with half a brain knows to use tables for tabular data. And non-tabular data gets marked up in it’s own semantic way.
If people are actually doing this kind of thing, then I agree, that IS madness. But surely this isn’t a wide-spread trend. Is it?
I agree with Sam. There is certainly a huge portion of otherwise bright developers who still have the impression that is almost a deprecated tag. So much so that some time ago some folks opted to even reproduce the look of a table with definition lists (), not considering that the use was completely nonsemantic.
Sorry, my html tags got removed instead of turned into HTML entities…
“still have the impression that TABLE is almost a deprecated tag”
“definition lists (DL)”
@JP, there are more than enough examples I have come across (but not saved) that show that this is not an aberration. Whether it is because people don’t know any better, or they are misguidedly trying to ‘protect their information from being copied’, there are people who are doing this and need to be educated otherwise. I’m currently writing up a tutorial that goes through the different ways to markup and present tables in HTML that will hopefully prove a valuable source for some.
Tables absolutely *are recommended… for tabular data.
They’re just not recommended for page layout.
I agree, but the issue still stands that people have been yelling “DON’T USE TABLES” for so long that newer developers are neglecting to use them in situations when they probably should be.
People do not seem to understand what semantic means, nor do they care, so until such time comes where people apply the right tag to the right piece of content, the rule will continue to be STOP USING TABLES YOU NOOB! When they finally learn how to use other tags, then we can let the retards use the table tag again. /rant
The call when ‘NOOBs’ do use tables for page design should be “ONLY USE TABLES FOR TABULAR DATA” anything else will just drive them away from using tables correctly in the future.