HTML Tables Tutorial

Page 8 - <table> cellpadding


Cellpadding is the amount of pixels inside table cells before content is drawn inside of them. By default there is about 1 pixel inside table cells. This must also (see cellspacing) be overridden so that images bound in a table are right next to one another. The first example shows the default. The second example shows what happens when cellpadding is set to zero. The last example shows a higher value of cellpadding.
<table border="1">
   <tr>
      <td>Cell #1</td>
      <td>Cell #2</td>
   </tr>
   <tr>
      <td>Cell #3</td>
      <td>Cell #4</td>
   </tr>
</table>
=
Cell #1 Cell #2
Cell #3 Cell #4

<table border="1" cellpadding="0">
   <tr>
      <td>Cell #1</td>
      <td>Cell #2</td>
   </tr>
   <tr>
      <td>Cell #3</td>
      <td>Cell #4</td>
   </tr>
</table>
=
Cell #1 Cell #2
Cell #3 Cell #4
(note that the content is slightly closer to the border)

<table border="1" cellpadding="15">
   <tr>
      <td>Cell #1</td>
      <td>Cell #2</td>
   </tr>
   <tr>
      <td>Cell #3</td>
      <td>Cell #4</td>
   </tr>
</table>
=
Cell #1 Cell #2
Cell #3 Cell #4
 
 
MPF.com Site Map