Thursday, August 18, 2011

Tables and the Border Attribute


To display a table with borders, to use the border attribute:

 

<table border="1">

<tr>

<td>Row 1, cell 1</td>

<td>Row 1, cell 2</td>

</tr>

</table>




row 1, cell 1
row 1, cell 2
row 2, cell 1


Note that the borders around the empty table cell are missing (NB! Mozilla Firefox displays the border).

To avoid this, add a non-breaking space (&nbsp;) to empty data cells, to make the borders visible:

 

<table border="1">

<tr>

<td>row 1, cell 1</td>

<td>row 1, cell 2</td>

</tr>

<tr>

td>row 2, cell 1</td>

<td>&nbsp;</td>

</tr>

</table>


No comments:

Post a Comment