Supported by :   My Law Forms Ltd. - Deed polls and Tenancy Agreements

CSS Tip: CSS Equivalent to CELLSPACING=0

table.jpgWhen 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 :-

border-spacing: 3px;

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 :

border-spacing: 3px;
border-collapse: collapse;

The full affect of table cellspacing with a CSS only solution.

This entry was posted on Wednesday, February 20th, 2008 at 3:10 pm and is filed under CSS Tips, HTML help, XHTML tips. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Comments are closed.