HTML Tables Tutorial

Page 7- <table> cellspacing


Cellspacing is the amount of pixels between table cells. By default there are about 2 pixels between table cells, that is why there is white space between the borders. Many times this must 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 cellspacing is set to zero. The last example shows a higher value of cellspacing.
<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" cellspacing="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 the solid border)

<table border="1" cellspacing="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