Welcome to WebmasterWorld Guest from 54.144.44.9

Forum Moderators: not2easy

Message Too Old, No Replies

CSS table properties

"cellspacing", "cellpadding" and "border"?

     
9:53 pm on Nov 12, 2002 (gmt 0)

Full Member

10+ Year Member

joined:Aug 31, 2002
posts:284
votes: 0


Could someone tell me if there are CSS equivalents for the table properties "cellspacing", "cellpadding" and "border".

Thanks.

9:54 pm on Nov 12, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member mivox is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Dec 6, 2000
posts:3928
votes: 0


If you're using a table, what's wrong with using the standard table attributes to control it?
10:00 pm on Nov 12, 2002 (gmt 0)

Full Member

10+ Year Member

joined:Aug 31, 2002
posts:284
votes: 0


I want as much HTML as possible to be repaced with CSS for SEO reasons
10:04 pm on Nov 12, 2002 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lorax is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Mar 31, 2002
posts:7575
votes: 0


Check out the Box Model [w3.org]

In short either margin or padding for the spacing issues and then border for ... well a border! Borders need to be defined by color, linetype and line thickness if you declare it all on one line (border : 1px solid black;)

10:10 pm on Nov 12, 2002 (gmt 0)

Full Member

10+ Year Member

joined:Aug 31, 2002
posts:284
votes: 0


thanks, so if I wanted to replecate

<table cellspacing="0" cellpadding="0" border="0">

...any tips on going about that?

Table {
border-spacing: 0px;
}

seems to do the border job.

10:24 pm on Nov 12, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member mivox is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Dec 6, 2000
posts:3928
votes: 0


I think you'd end up with code bloat if you tried to use CSS for setting padding on each and every table cell... it's not really designed to supercede the traditional table attributes when using tables in a layout.

I doubt you'll see much (if any) SEO advantage to that approach, and I don't think CSS can control the cellspacing at all. (…but I could be wrong there)

10:41 pm on Nov 12, 2002 (gmt 0)

Full Member

10+ Year Member

joined:Aug 31, 2002
posts:284
votes: 0


yeah, that's the way I was beginning to see things.

Thanks for all the pointers.

2:18 am on Nov 13, 2002 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lorax is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Mar 31, 2002
posts:7575
votes: 0


If you're going to use CSS to control style then you might want to consider going the XHTML with CSS route and get rid of the tables altogether. There have been numerous threads (both for and against this) at WebmasterWorld so I'm sure you'll find lots of good reading if you do a search on any one or more of the terms 'xhtml tables css tableless positioning css2p'

Good luck and have fun!

3:38 am on Nov 13, 2002 (gmt 0)

Preferred Member

10+ Year Member

joined:May 1, 2002
posts:351
votes: 0


so if I wanted to replecate

<table cellspacing="0" cellpadding="0" border="0">

...any tips on going about that?

table {
[url=http://www.w3.org/TR/CSS2/tables.html%23propdef-border-collapse]border-collapse[/url]: collapse;
}
td {
padding: 0;
}

As with most things CSS, this won't work in Netscape 4.x or other older browsers.

Instead of looking at the box model, for this problem you would be more interested in the section entitled tables in the visual formatting model [w3.org]. Of course, you should learn the box model anyway ...

[edited by: tedster at 8:40 am (utc) on Nov. 13, 2002]
[edit reason] link fix [/edit]

8:38 am on Nov 13, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:May 26, 2000
posts:37301
votes: 0


Thanks for that, moonbiter. I think this is the first post where anyone pointed out the border-collapse rules. I know they're new to me.

Will my CSS homework never stop?

11:01 am on Nov 13, 2002 (gmt 0)

Preferred Member

10+ Year Member

joined:Aug 28, 2002
posts:564
votes: 0


A table is often the right thing to use, even in a css layout: for tabular data (naturally) and for when you want to keep particular page elements in close proximity.

A table should make sense with css turned off, so it is perfectly ok to use the table attributes of border, cellpadding etc.

CSS styles are supposed to override table attributes, so you can add and change presentation effects with css. (This doesn't always work perfectly, so you have to test.)

2:11 pm on Nov 13, 2002 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lorax is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Mar 31, 2002
posts:7575
votes: 0


Ya Moonbiter - Thanks. Just when I thought I had a handle on borders! :)
4:53 pm on Nov 13, 2002 (gmt 0)

Preferred Member

10+ Year Member

joined:May 1, 2002
posts:351
votes: 0


Will my CSS homework never stop?

Mine hasn't. We're all beginners at this: take a look at the CSS 3 Drafts [w3.org] if you don't believe me. ;)

BTW: If you are using Mozilla and hate the default style of the W3C's CSS site, check out View > Use Style on your browser menu. I think this option is also available in Opera, isn't it?