When using the TABLE tag, there are two attributes that are commonly added; cellspacing and cellpadding. For padding, there is an obvious match with the CSS definition padding. Indeed the attribute for padding-top, padding-bottom, padding-left and padding-right all behave as expected. However there is no directly corresponding property for cellspacing. One might assume that the margin property would provide the same functionality and layout control, but it does not apply to table cells.
It may be tempting to simply include the cellpadding attribute within the table, though there is a CSS equivalent that can be used :-
This allows the spacing between cells to be controlled the same as would be possible with cellspacing but with a CSS only solution.
One of the commonest reasons for using cellspacing is to remove any spacing at all from table cells, with cellspacing=0. Historically this has been when tables are used for layout purposes. Whilst this is no longer advisable for layout, there are times when tabular data can benefit for zero spacing. With CSS this can be accomplished as follows :
The full affect of table cellspacing with a CSS only solution.