HTML Tables - Cellpadding and Cellspacing
(Page 5 of 7 )
To create more space between the data in a cell and the borders that surround it, we use cellpadding. To increase the space between cells, we use cellspacing. The sample below demonstrates their use:
<html>
<body>
<h2>No Cellpadding or Cellspacing:</h2>
<table border="1">
<tr>
<td>Peter</td>
<td>Griffin</td>
</tr>
<tr>
<td>Lois</td>
<td>Griffin</td>
</tr>
</table>
<h2>Cellpadding and Cellspacing:</h2>
<table border="1"
cellpadding="12" cellspacing="10">
<tr>
<td>Brian</td>
<td>Griffin</td>
</tr>
<tr>
<td>Stewie</td>
<td>Griffin</td>
</tr>
</table>
</body>
</html>
Here is what will be displayed in the user's browser:
No Cellpadding or Cellspacing:
Cellpadding and Cellspacing:
Brian | Griffin |
Stewie | Griffin |
Next: Setting Backgrounds in Tables and Cells >>
More HTML Articles
More By James Payne