When colspan property doesn’t appear to work in Firefox or Safari

When building web applications I often use display styles to show or hide divs or table rows as needed. On one project, I found that the “colspan” property did not seem to work in Firefox or Safari. This was because I had incorrectly used “display:block” to style the TR element, instead of “display:table-row.” A demo is below, and the code follows.

Demo using “display:block”

I used display:block on this table. This th should span 3 columns
cell 1 cell 2 cell 3

Demo using “display:table-row”

I used display:table-row on this table. This th should span 3 columns
cell 1 cell 2 cell 3

The Code that produced the two tables above:

<table border=1>
<tr style="display:block">
<th colspan="3">
Using display:block on this table. This th should span 3 columns
</th>
</tr>
<tr>
<td>cell 1</td>
<td>cell 2</td>
<td>cell 3</td>
</tr>
</table>
<table border=1>
<tr style="display:table-row">
<th colspan="3">
Using display:table-row on this table. This th should span 3 columns
</th>
</tr>
<tr>
<td>cell 1</td>
<td>cell 2 </td>
<td>cell 3</td>
</tr>
</table>