views:

169

answers:

3

If this is the structure:

<table cellspacing="0" cellpadding="0">
   <tr>
      <td>I don't need anything here, should I always put a &nbsp; here?</td>
      <td>item </td>
   </tr>
   <tr>
      <td>model</td>
      <td>one</td>
   </tr>
   <tr>
      <td>model</td>
      <td>two</td>
   </tr>
   <tr>
      <td>model</td>
      <td>three</td>
   </tr>
</table>

How will a screen reader read a blank td? Is it semantically correct?

+2  A: 

Semantically correct IMHO would be to keep an empty cell really empty. However, I, too, fill empty cells with &nbsp;s for pragmatic reasons.

As for screen readers, I'll have to make an educated guess: Empty nodes will likely not be read, because HTML consists mostly of whitespace text nodes, which readers ignore, and I assume, that &nbsp; is collapsed to a simple space in reader applications (since non-breaking is a property of visual media).

For rendering visually, one could rely on the CSS table property empty-cells:

table {
    empty-cells: show;
}
Boldewyn
I think this property is not supported in IE
metal-gear-solid
That's true, and the reason, why I still use ` `s, unfortunately.
Boldewyn
+1  A: 

Hi, there isn't anything exactly saying you shouldn't use use a blank TD, and it passes when you try to validate.

Although, a more elegant approach would be to use colspan.

i.e.

<tr>
   <td colspan="2">item </td>
</tr>

But this will align your content to the left, and you will have to manually (via css) apply styles so the content is aligned where you want.

The good thing about using it with colspans, is that screen readers will read only what's there, and not the empty spaces

Marcos Placona
The `colspan` is not necessary more elegant or semantic. `colspan` says effectively, that the value of the table cell is a valid combination of values that usually would belong in two different cells. In the above case: If the first row is a heading, then `colspan` gives a completely wrong result (i.e., the cell content is marked up as label for *both* columns).
Boldewyn
A: 

Thanks to editors like Dreamweaver this practice became somewhat of a standard, so even if it is not a perfect solution - at least you won't be alone in doing it. Plus it is more compatible with older browser than CSS's empty-cells.

Alex T.