Forum Moderators: open
<table border="1">
<tr><td>some content</td><td style="background-color: #c0c0c0"></td><td></td></tr>
<tr><td></td><td style="background-color: #c0c0c0"></td><td>below is no content</td></tr>
<tr><td></td><td style="background-color: #c0c0c0"></td><td></td></tr>
</table>
Then with , but note the height of the last row:
<table border="1">
<tr><td>some content</td><td style="background-color: #c0c0c0"> </td><td> </td></tr>
<tr><td> </td><td style="background-color: #c0c0c0"> </td><td>below is no content</td></tr>
<tr><td> </td><td style="background-color: #c0c0c0"> </td><td> </td></tr>
</table>
You will find some unrendered cells without something in the cells, and will see missing background colors. In the last example, the vertical spacing in the cells will vary with the font size used on the page. This is where the damnable spacer made it's debut. By putting a 1X1 pixel spacer in the cells and sizing it as required, it would "lock in" the size of the cells, as long as the cellpadding and cellspacing are set to 0:
<table border="1" cellpadding="0" cellspacing="0">
<tr>
<td>some content</td>
<td style="background-color: #c0c0c0"><img src="spacer.gif" width="23" height="1" alt=""></td>
<td><img src="1x1_spacer.gif" width="23" height="1" alt=""></td>
</tr>
<tr>
<td><img src="1x1_spacer.gif" width="23" height="1" alt=""></td>
<td style="background-color: #c0c0c0"><img src="1x1_spacer.gif" width="23" height="1" alt=""></td>
<td>below is no content</td>
</tr>
<tr>
<td><img src="1x1_spacer.gif" width="23" height="1" alt=""></td>
<td style="background-color: #c0c0c0"><img src="1x1_spacer.gif" width="23" height="1" alt=""></td>
<td><img src="1x1_spacer.gif" width="23" height="1" alt=""></td>
</tr>
</table>
So if you're using tables, it's a good idea to put *something* in empty cells. But if the table is used for layout, you shouldn't be using tables. :-)
I don't think it's so much a 'rule' as a way of helping the page to look the same in all browsers
But if the table is used for layout, you shouldn't be using tables.
So until the average html coder can do pure css, we use tables (in order to stay in business).
Does anyone know if a highly respected site about html (w3c, government, etc) with a reference to not having empty table cells?
...the empty-cells property for table cells is supported by css
I would still rather not allow empty table cells because of the problems. But it looks like I can't say 'its official'. I have to say 'its my personal preference'.
Wow! thats interesting. So that means problems with empty cells not rendering are due to browsers not conforming to standards?
not necessarily.
i'm not sure there is a standard for rendering empty cells.
however you can probably enforce your preferred standard behavior in css-compliant browsers by specifying it in your stylesheet.
There's certainly a valid argument that you 'should' use css - and many of us would love to - but there's an equally valid response "I'll wait until the 'official' code looks the same in all common browsers, thanks."
That day will surely come; but it is a problem for the browser-makes and the code folk; it is not a 'rule' - yet - and so people are perfectly entitled to use tables for layout until they get their act together.
I would still rather not allow empty table cells because of the problems. But it looks like I can't say 'its official'. I have to say 'its my personal preference'.
You could simply tell them it looks sloppy, because the empty cells are inconsistent.
I have no idea why they would argue about this. It would be faster to just fix it. A professional wouldn't think of delivering something like that.
Cells may be empty (i.e., contain no data).
Myself, I add a non-breaking spacer and assign a class of 'empty' to the cell. this way I can control the way it is rendered, IE: padding, line-height, font-size, etc.