#1
  1. Wiser? Not exactly.
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2001
    Location
    Bonita Springs, FL
    Posts
    5,959
    Rep Power
    4035

    CSS to control CELLSPACING in tables


    I'm wondering if there is any CSS element that can control the cellspacing attribute of a table. I'm making a PHP script that will output tables to show some information, and the output will be put into a template. Inorder to allow people to control the looks of what my script makes, i've been giving everything an ID. The only thing so that that I havn't been able to do, is set the table's cellspacing attribute to 0 so that there is no space between the borders.

    Here is a sample page of that it will currently do as apposed to what I want it to do.

    http://kicken.mine.nu:8008/extras/spacing.html

    In the second table, I set the cellspacing to 0 so you can see, but I want to be able to use CSS to do that.

    Anyone know of any property(margin: and padding: don't work, tried both) that I may be looking for?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2002
    Location
    Norwich, UK
    Posts
    53
    Rep Power
    13
    Bottom line: I don't think it's possible.

    I wanted to set cellspacing using CSS a while back, after some extensive testing and trawling through the CSS2 specification a few times I came up with nothing. In the end I had to manipulate the table's cellSpacing property via JavaScript. I can't help but feel that I missed something though, why on Earth it wouldn't be available is beyond me...
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Nov 2001
    Posts
    1,882
    Rep Power
    20
    http://www.w3schools.com/css/pr_tab_border-collapse.asp

    Code:
    <table width="100" border="1" style="border-collapse: collapse">
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
    </table>
  6. #4
  7. Wiser? Not exactly.
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2001
    Location
    Bonita Springs, FL
    Posts
    5,959
    Rep Power
    4035
    Ahh, so that's what that does. Changes the color a bit but that's no big deal. Thanks degsy
  8. #5
  9. No Profile Picture
    Senior Citizen
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2001
    Location
    leftcoast
    Posts
    2,019
    Rep Power
    16
    border-collapse is crucial here - but cellspacing is done to individual tds using margin, and cellpadding uses, hem, padding, also applied to the cell. If you apply them to the table element, the entire table gets spaced/padded (as a block).

IMN logo majestic logo threadwatch logo seochat tools logo