Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Jul 2007
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cellspacing in CSS - Solved!

    Hi,

    At long last, I've managed to figure out how to emulate the HTML cellspacing attribute in CSS. So I thought that I'd post it here so everyone can use it.

    Here's the code:
    Code:
    .cellspacing td {
    	border-right : 3px solid #FFF;
    }
    .cellspacing td:last-child {
    	border-right : 0px;
    }
    .cellspacing th {
    	border-right : 3px solid #FFF;
    }
    .cellspacing th:last-child {
    	border-right : 0px;
    }
    Just add the cellspacing class to a table tag and it creates a white 3px border between each column throughout the table.

    It's a shame the CSS designers haven't made this easier by having a proper built-in cellspacing attribute, but until they do, this is the next best thing, I guess.

    Enjoy.

    Debbie
    QuicknEasySalesPro.com - your quick and easy, yet powerful solution for managing your membership site sales, downloads and affiliates.

  • #2

  • #3
    New Coder
    Join Date
    Jul 2007
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Sammy12,

    No, not advertising, just giving something back to all the forums (fora?) that I've used over the years.

    It may not work with some older versions of some browsers, though, because the :last-child pseudo class has only just become supported in some of them, which I guess is why it's only now that I've be able to find this solution.

    Debbie
    QuicknEasySalesPro.com - your quick and easy, yet powerful solution for managing your membership site sales, downloads and affiliates.

  • #4
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,784
    Thanks
    6
    Thanked 1,022 Times in 995 Posts
    Quote Originally Posted by Debbie-Leigh View Post
    It's a shame the CSS designers haven't made this easier by having a proper built-in cellspacing attribute, […]
    Have you never heard of the border-spacing property?

  • #5
    Registered User
    Join Date
    Jun 2011
    Posts
    1,063
    Thanks
    12
    Thanked 241 Times in 240 Posts
    Quote Originally Posted by Debbie-Leigh View Post
    Hi Sammy12,

    No, not advertising, just giving something back to all the forums (fora?) that I've used over the years.

    It may not work with some older versions of some browsers, though, because the :last-child pseudo class has only just become supported in some of them, which I guess is why it's only now that I've be able to find this solution.

    Debbie
    that's good to hear. i just can't stand when i spend my time reading a post and find it's commercial. there's a fine line between a post like this and commercial use. I just hope that line stays 1px solid.

  • #6
    New Coder
    Join Date
    Jul 2007
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Sammy12,

    :-) Yes, I hope so too.

    Hi VIPStephan,

    Yep, tried it, but it only produces a border around the table, not between cells in the same way that cellspacing does. That's one reason why I ended up with this solution.

    There may be other ways to achieve the same effect, but this is the one I've found that works, so I thought I'd share it, so others who have also been tearing their hair out don't have to anymore.

    Debbie
    QuicknEasySalesPro.com - your quick and easy, yet powerful solution for managing your membership site sales, downloads and affiliates.

  • #7
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,784
    Thanks
    6
    Thanked 1,022 Times in 995 Posts
    Quote Originally Posted by Debbie-Leigh View Post
    Hi VIPStephan,

    Yep, tried it, but it only produces a border around the table, not between cells in the same way that cellspacing does.
    That can’t be true. In which browser (and version) have you experienced this? Look again at the link I provided above. The cells displayed there are all separate for me in Firefox 5.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •