homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderators: not2easy

CSS Forum

is there any css equ to table cellspacing
just a quick question

 5:22 am on Mar 17, 2003 (gmt 0)

thx :)
if yes, which version of browsers support it?



 6:15 am on Mar 17, 2003 (gmt 0)

Depends what exactly you are looking for.

This distance between adjacent element borders is controlled by margin and the distance between an element and its own border is controlled by padding

Both should be very well supported.

So if you have html like this..

<div id="div1">
Div One

<div id="div2">
Div Two

and you have CSS like this..

#div1 {
border: 1px dashed red;
padding: 20px;
margin: 40px;

#div2 {
border: 1px dashed green;
padding: 5px;
margin: 10px;

You should end up with two boxes one above the other. The content of the top box will keep at least 20 pixels away from its edge and the content of the bottom box will stay 5 pixels from the edge.

The two boxes will be 40 pixels apart (note 40, not 50, because margins collapse together)

If don't want a uniform margin then you can specify it as margin: 1px 2px 3px 4px;, which specifies top,right,bottom,left margins in that order.


 6:37 am on Mar 17, 2003 (gmt 0)

thx, but sorry, what i want is for cellspacing of table
not for enum "table and cellspacing"
apologize for my bad question


 8:31 am on Mar 17, 2003 (gmt 0)

Hi try this, The border-collapse and border-spacing properties. [w3.org]



 8:51 am on Mar 17, 2003 (gmt 0)

hrm... it's right but seems ie don't support it, i give up :(


 12:34 pm on Mar 17, 2003 (gmt 0)

Why not just use the cellspacing attribute? Its still part of the HTML4.01 Strict doctype.

Alternatively, if you have to do it with CSS then bear in mind that you can still specify internal padding of cells.

table td {
padding: 5px;

which will look pretty much the same as cellspacing if you are not displaying cell borders.

If you need to display a border for your cell content then you could fake it by doing something cheesy like this..

table td {
padding: 5px;
border: none;
table td div {
padding: 1px;
border: 1px solid black;
<td><div>Cell 1</div></td>
<td><div>Cell 2</div></td>
<td><div>Cell 3</div></td>
<td><div>Cell 4</div></td>

Which is pretty horrible, but it works. ;)


 2:47 pm on Mar 17, 2003 (gmt 0)

thx :)
it's very kind of u guys

i wanted to uses css cos my table is built by my program
so i wanna customize it in css
this make me to reduce the count of params to the table maker function

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / CSS
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved