Search code examples
xhtmlsemantic-markup

Proper definition for "tabular data" in HTML


I have a pedantic argument that needs resolution.

As a proper koolaid drinker when it comes to HTML, I'm all about semantic markup. As a result, of course I hate to see tables where they don't belong. The rule of thumb for tables is that you should only use them for "tabular data", but it has come to my attention that this is a really poorly defined phrase. I wanted to make the following data a table, but others at my office disagreed that a table would be semantically correct in this case (as opposed to a dl or ul, etc):

------------------
| SomeEmployee   |
|----------------|
| Field    | val |
| Field    | val |
| Field    | val |
| Field    | val |
------------------

Asking around the office (and the interwebs), I got some of the following answers on what makes data "tabular":

  • "Anything that you would put in a spreadsheet" (I've seen entire design mockups created in spreadsheets, so this seems somewhat lacking to me)
  • Data that would map well to a database table (e.g. row and column data, specifically)
  • "Text, preformatted text, images, links, forms, form fields, other tables, etc." (thanks W3C, that's really helpful)

And so on and so forth. None of these seem to be canonical definitions, and they don't provide great dividing lines to make decisions on. So, I ask you, my clever compatriots: how should we define tabular data.

If at all possible, please cite the sources for your answers to prevent a string of "well I think" answers.

Thanks!

Joe


Solution

  • Wikipedia has some down-to-earth rules in its internal article-writing guidelines. They're far from an exhaustive definition but work well in real-world use IMO.

    The whole definition is worth reading, but one paragraph strikes me as especially nice:

    Before you format a list in table form, consider whether the information will be more clearly conveyed by virtue of having rows and columns. If so, then a table is probably a good choice. If there is no obvious benefit to having rows and columns, then a table is probably not the best choice.