Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-02-2011, 02:04 AM   PM User | #1
Debbie-Leigh
New Coder

 
Join Date: Jul 2007
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Debbie-Leigh is an unknown quantity at this point
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.
Debbie-Leigh is offline   Reply With Quote
Old 08-02-2011, 03:11 AM   PM User | #2
Sammy12
Registered User

 
Join Date: Jun 2011
Posts: 1,063
Thanks: 12
Thanked 241 Times in 240 Posts
Sammy12 is on a distinguished road
http://www.webdeveloper.com/forum/sh...58#post1166358

http://www.codeguru.com/forum/showthread.php?p=2026879

seems a lot like advertising

---

all your posts do

http://www.google.com/search?rlz=1C1CHOL_enUS415US415&sourceid=chrome&ie=UTF-8&q=I'm+trying+to+get+top+both+corners+of+my+table+header+row+to+have+a+rounded+corner+each%2C+but+o nly+one+is+appearing.

slippery one
Sammy12 is offline   Reply With Quote
Old 08-02-2011, 10:17 AM   PM User | #3
Debbie-Leigh
New Coder

 
Join Date: Jul 2007
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Debbie-Leigh is an unknown quantity at this point
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.
Debbie-Leigh is offline   Reply With Quote
Old 08-02-2011, 12:11 PM   PM User | #4
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,613
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
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?
__________________
Don’t click this link!
VIPStephan is online now   Reply With Quote
Old 08-02-2011, 06:32 PM   PM User | #5
Sammy12
Registered User

 
Join Date: Jun 2011
Posts: 1,063
Thanks: 12
Thanked 241 Times in 240 Posts
Sammy12 is on a distinguished road
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.
Sammy12 is offline   Reply With Quote
Old 08-02-2011, 08:39 PM   PM User | #6
Debbie-Leigh
New Coder

 
Join Date: Jul 2007
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Debbie-Leigh is an unknown quantity at this point
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.
Debbie-Leigh is offline   Reply With Quote
Old 08-02-2011, 08:51 PM   PM User | #7
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,613
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
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.
__________________
Don’t click this link!
VIPStephan is online now   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:44 AM.


Advertisement
Log in to turn off these ads.