I have an HTML table containing a few rows (this is built dynamically). All <tr>s have one <td> inside.
If one <td> doesn’t have HTML content inside, I would like it to be invisible.
How can this be done? (Not that the HTML inside is rendered dynamically and I do not want to use display:none or any other property on the <td> or <tr>).
Code sample:
<html>
<body bgcolor="#E6E6FA">
<table cellSpacing="0" cellPadding="0">
<tr>
<td>one cell</td>
</tr>
<tr>
<td bgcolor="#FF0000"></td>
</tr>
<tr>
<td>two cell</td>
</tr>
</table>
</body>
</html>
In Firefox the empty TD is invisible. However, in IE the TD takes up 1 pixel in height:

Looking with DOM Inspector I see that it takes 1 pixel:

How can I set the TD not to be visible? Any scripts I can execute inside the TD?
You can use the CSS pseudo selector
:empty:jsFiddle example: http://jsfiddle.net/vKEBY/6/
And if you want to support IE<9:
jsFiddle example: http://jsfiddle.net/vKEBY/6/