cellpadding & cellspacing - there is substitute in CSS?

Discussion in 'CSS' started by Ohad, Apr 24, 2008.

  1. #1
    table cellpadding & cellspacing - there is substitute in CSS?
    Thanks!
     
    Ohad, Apr 24, 2008 IP
  2. PHPGator

    PHPGator Banned

    Messages:
    4,437
    Likes Received:
    133
    Best Answers:
    0
    Trophy Points:
    260
    #2
    For padding there is for sure. I think you just use padding: 5px; <- or something like this. You can even be more specific and do padding-top: 5px;
     
    PHPGator, Apr 24, 2008 IP
  3. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Well, the equivilant of cellpadding="0" cellspacing="0", there's

    table {
    border-collapse: collapse;
    }

    The default value for border-collapse is "seperate" which makes borders. If you have borders (seperate) and have cells you don't want to show because they're empty <td></td>, set that whole table to

    empty-cells: hide;

    The default is "show" meaning their borders would get rendered.

    Otherwise, to set borders, you can say
    td {
    border: 1px solid whatevercolor;
    }

    although what I end up doing is setting only borders for two sides and the table itself, which looks better.

    Padding is added to the td itself (td {padding: 5px;}), while increasing the spacve between them is increasing the width of the borders.

    I'm not sure what you'd do if you truly need transparent space between the cells-- I normally have a solid background colour and the borders are the same colour, so it looks like "cellspacing" but it isn't, really, if there's an image in the background of the table or behind the table.
     
    Stomme poes, Apr 24, 2008 IP
  4. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #4
    The css equivalent of cell-spacing is border-spacing. The trouble is, IE doesn't support it. You'll have to stay with the html attribute for now.

    cheers,

    gary
     
    kk5st, Apr 25, 2008 IP