CSS alternatives
Cell padding may be handled by applying the padding
property to the td
element. By using class
, id
, or more specific selectors, it is
possible to apply different amounts of padding to different cells
within a table (the cellpadding
attribute applies the same amount of padding to all cells).
There is no CSS property that is exactly equivalent to the
cellspacing
attribute, although you
can adjust the amount of space between cells by setting the border-collapse
property for the table to
separate
and then use the border-spacing
property to specify the
amount of space between cell borders . The difference is that with the cellspacing
attribute, the border is
rendered thicker between cells, while the border-spacing
property adds empty space
between them.
Unfortunately, the border-spacing
property is not supported by
Internet Explorer 6 and earlier (support in IE 7 is not documented as
of this writing), so authors are left with no practical CSS cellspacing
substitute for the time
being.
Tip
Many authors also explicitly set both the cellspacing
and cellpadding
to 0 (zero) to override
default browser settings and clear the way for style sheet
properties.
Get Web Design in a Nutshell, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.