Previous Message
Next Message

Re: [css-d] cell-spacing

Sent by Eric A. Meyer on 30 January 2002 12:12

At 9:54 +0100 1/29/02, Mark Howells wrote:

>'cell-spacing' isn't in CSS up to v2.0 as far as I know.

    That's correct.  Several books, one of my own included, list 
'cell-spacing' as a property in CSS2.  It isn't[1].  'border-spacing' 
is the closest equivalent, although it's a little more flexible.  For 
example, you can say:

    table {border-collapse: separate; border-spacing: 2px 5px;}

This will cause cells within a table to be separated by 2px 
horizontally and 5px vertically.
    Two points to note: first, 'border-spacing' has no effect unless 
you set 'border-collapse' to 'separate', as I did above.  The default 
value for the property is 'collapse', so you have to make the 
declaration yourself.  Second, 'border-spacing' (and 'empty-cells') 
can be applied only to table elements, not to the cells within them. 
In other words, you can define a table-wide 'border-spacing' but you 
can't set different spacing for individual cells.

>I use td {margin:0} for cellspacing and td {padding:0} for cellpadding.

    The second part is true, but the first is not.  Margins don't 
apply to table cells, interestingly enough.  Browsers may try to 
handle a table cell's margin but they shouldn't.

[1] I can't remember now if it was proposed but dropped, or if some 
authors just had a collective hallucination about its existence.

Eric A. Meyer (, List Chaperone
"CSS is much too interesting and elegant to be not taken seriously."
   -- Martina Kosloff
Previous Message
Next Message

Message thread: