<<< Home << Web < HTML Notes Top Bottom < Prev Next >

Closing Tags in Tables

The HTML specs define the </tr>, </td> and </th> closing tags as optional. However, I had heard reports that Netscape has problems with nested tables when they are omitted.

I finally got around to testing this, and was able to cause the problem on my first try. Here's two versions of the same nested table. The only difference is that the first includes the closing tags, and the second omits them.

<!-- Table with closing tags -->
<table border="9" cellpadding="3" cellspacing="0">
  <tr>
    <td width="100" bgcolor="#ff0000"> <br> </td>
    <td>
      <table border="1" cellspacing="0" cellpadding="5">
        <tr>
          <td> cell 1 </td>
          <td> cell 2 </td>
        </tr> <tr>
          <td> cell 3 </td>
          <td> cell 4 </td>
        </tr>
      </table>
    </td>
    <td width="100" bgcolor="#ff0000"> <br> </td>
  </tr>
</table>

<!-- Table without closing tags -->
<table border="9" cellpadding="3" cellspacing="0">
  <tr>
    <td width="100" bgcolor="#ff0000"> <br>
    <td>
      <table border="1" cellspacing="0" cellpadding="5">
        <tr>
          <td> cell 1
          <td> cell 2
        <tr>
          <td> cell 3
          <td> cell 4
      </table>
    <td width="100" bgcolor="#ff0000"> <br>
</table>

IE was able to display both tables correctly - there was no difference in appearance. But Netscape definitely got confused. This was true in both Netscape 3 and Netscape 4.5.

Netscape 4.5 with and without closing tags

Bad, Netscape! Bad! Bad!

Obviously, you want to include the closing tags, at least for nested tables. You might as well do it all the time, just to get in the habit.


<<< Home << Web < HTML Notes Top Bottom < Prev Next >