HTML tables: Why not column based tables in addition to row based tables?

The current table construction requirements insist that you specify tables first by rows, then by columns. This may make it easier to write web browsers and ensures compatibility, but it also makes it harder to write tables. Shouldn’t language usability by the code writer also be a primary concern?

For instance, consider the following potential table fodder:

X Y
1 1
2 4
3 9

My natural instinct is to write it by column, as the rows do not have enough meat on them, nor are they even how the table is naturally organized. If it would work, I would implement it this way:

<TABLE>
<CAPTION>Y vs. X</CAPTION>
<TC><TH>X</TH><TD>1</TD><TD>2</TD><TD>3</TD></TC>
<TC><TH>Y</TH><TD>1</TD><TD>4</TD><TD>9</TD></TC>
</TABLE>

Hypothetically, the <TC></TC> tags would do for columns what the <TR></TR> tags do for rows. However, I am instead forced to do it this way:

<TABLE>
<CAPTION>Y vs. X</CAPTION>
<TR><TH>X</TH><TH>Y</TH></TR>
<TR><TD>1</TD><TD>1</TD></TR>
<TR><TD>2</TD><TD>4</TD></TR>
<TR><TD>3</TD><TD>9</TD></TR>
</TABLE>

While it is easier to guess at the latter’s layout, it requires more glancing back and forth between a handwritten or dictated table, and it requires more tags. In short, it unnecessarily takes more time. The argument could be made that the data might make a better horizontal table anyway, but that implies that a vertical table is not as valid a means of presentation, which isn’t necessarily true.

At http://www.w3.org/TR/html401/struct/tables.html, the following table is shown:

<TABLE summary="This table charts the number of cups
                   of coffee consumed by each senator, the type 
                   of coffee (decaf or regular), and whether 
                   taken with sugar.">
<CAPTION>Cups of coffee consumed by each senator</CAPTION>
<TR>
   <TH>Name</TH>
   <TH>Cups</TH>
   <TH>Type of Coffee</TH>
   <TH>Sugar?</TH>
<TR>
   <TD>T. Sexton</TD>
   <TD>10</TD>
   <TD>Espresso</TD>
   <TD>No</TD>
<TR>
   <TD>J. Dinnen</TD>
   <TD>5</TD>
   <TD>Decaf</TD>
   <TD>Yes</TD>
</TABLE>

This table is clearly organized by column rather than row. I’m inclined to think that it would be easier to write as columns as well. Let’s see:

<TABLE summary="This table charts the number of cups
                   of coffee consumed by each senator, the type 
                   of coffee (decaf or regular), and whether 
                   taken with sugar.">
<CAPTION>Cups of coffee consumed by each senator</CAPTION>
<TC>
   <TH>Name</TH>
   <TD>T. Sexton</TD>
   <TD>J. Dinnen</TD>
<TC>
   <TH>Cups</TH>
   <TD>10</TD>
   <TD>5</TD>
<TC>
   <TH>Type of Coffee</TH>
   <TD>Espresso</TD>
   <TD>Decaf</TD>
<TC>
   <TH>Sugar?</TH>
   <TD>No</TD>
   <TD>Yes</TD>
</TABLE>

Now, if you were reading a chart, or having it dictated, you would naturally want to take down all the names first, then the cups, and so on. However, if you instead had separate records, you would want to implement each record at a time. How easy a table is to implement should not depend on how the information is required to come at you, and some superiority of horizontal over vertical; rather, ease of implementation should be a priority as well, regardless of context.

Please consider this.

Ryan Pettigrew

Received on Wednesday, 3 October 2007 13:40:50 UTC