homepage Welcome to WebmasterWorld Guest from 107.20.131.154
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Website
Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderators: DrDoc

CSS Forum

    
CSS table properties
"cellspacing", "cellpadding" and "border"?
Adam_C




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

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

Thanks.

 

mivox




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

If you're using a table, what's wrong with using the standard table attributes to control it?

Adam_C




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

I want as much HTML as possible to be repaced with CSS for SEO reasons

lorax




msg:1198909
 10:04 pm on Nov 12, 2002 (gmt 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;)

Adam_C




msg:1198910
 10:10 pm on Nov 12, 2002 (gmt 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.

mivox




msg:1198911
 10:24 pm on Nov 12, 2002 (gmt 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)

Adam_C




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

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

Thanks for all the pointers.

lorax




msg:1198913
 2:18 am on Nov 13, 2002 (gmt 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!

moonbiter




msg:1198914
 3:38 am on Nov 13, 2002 (gmt 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]

tedster




msg:1198915
 8:38 am on Nov 13, 2002 (gmt 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?

Longhaired Genius




msg:1198916
 11:01 am on Nov 13, 2002 (gmt 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.)

lorax




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

Ya Moonbiter - Thanks. Just when I thought I had a handle on borders! :)

moonbiter




msg:1198918
 4:53 pm on Nov 13, 2002 (gmt 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?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / CSS
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved