XML technologies / CSS / CSS Cookbook / Tables / Setting cell spacing

(Excerpt from “CSS Kochbuch” by Christopher Schmitt)

Problem

You want to set the gaps between the table border and the borders of individual cells.

Solution

Use the table attribute cellspacing:

<table cellspacing="15">
  <tr>
    <th colspan="2">Tabelle 1. Allgemeine statistische Angaben</th>
  </tr>
  <tr>
    <th></th>
    <th>Geschätzt</th>
  </tr>
  <tr>
    <td>Gesamtbevölkerung</td>
    <td>272.091</td>
  </tr>
</table>

Discussion

The CSS 2.1 specification describes a standard mechanism for manipulating the table attribute cellspacing. If the property border-collapse has the value separate, the property border-spacing can also be used:

border-collapse: separate;
border-spacing: 15px;

Unfortunately, this part of the specification is not implemented in Internet Explorer 6 for Windows, although it is in Firefox and Netscape Navigator 7+. Using the attribute cellspacing is therefore currently the best solution that also works in Internet Explorer for Windows.

See also

  

 

 

 

back to top