WebAIM - Web Accessibility In Mind

E-mail List Archives

Re: correct markup of empty cells in a data table

for

From: Jukka K. Korpela
Date: Mar 21, 2005 11:20PM


On Tue, 22 Mar 2005, steven.faulkner wrote:

> I have a data table that contains an empty cell "<td
> rowspan="5">&nbsp;"

Empty cells tend to cause problems. Quite often there is a better way,
typically the use of some characters that indicate _why_ the cell
does not contain normal data. In this case, I'm not sure.

> I am not sure if it is best marked up as a TH (as the other cells in the row
> are th) or as a TD

The HTML specification says that TD is a cell that contains table data
only, TH is a cell that contains a table header only, and for cells that
contain both should be marked up as TD. So a TD cell can be dual-purpose,
and could have a SCOPE attribute that tells how it acts as a header.
Somewhat oddly, the spec says this in a DTD comment only:
"TH is for headers, TD for data, but for cells acting as both use TD"
Ref.: http://www.w3.org/TR/html4/struct/tables.html#edef-TD

Thus, in borderline cases, TD would be more suitable in principle.

> does it matter?

Not much. It's difficult to say how it could matter. The spec says:
"Table cells may contain two types of information: header information and
data. This distinction enables user agents to render header and data cells
distinctly, even in the absence of style sheets. For example, visual user
agents may present header cell text with a bold font. Speech synthesizers
may render header information with a distinct voice inflection."
But how could such things matter when the cell contains a no-break space
only? And if a browser lets the user specify which data is to be presented
to the user, it may use TH elements and their attributes to decide how
this would take place. There's not much it could do with a TH cell
containing just a no-break space, could it?

> example code:

I think I understand the intended structure of the table, but it might not
be that obvious. How would you describe it in a SUMMARY attribute?
(I'm not saying you should write one; but it's often useful to think
what you would put there if you wrote it.) If the intent is that the
second cell in the first column emphasizes the meaning of the last two
rows, then this might work visually, but it makes the table somewhat
odd-looking, and would make aural rendering a little more confusing.

So I would suggest removing the entire first column, making the table
structure. For emphasis, you could use STRONG markup for the words
"Exited" and "Started" on the last two rows.

By the way, columns containing numbers are visually a little easier to
understand if they are right-aligned. It's easier to compare the numbers
that way.

--
Jukka "Yucca" Korpela, http://www.cs.tut.fi/~jkorpela/