Forum Moderators: not2easy

Message Too Old, No Replies

Do I still need to specify cellspacing=0 cellpadding=0

or can I just specify it once in the stylesheet?

         

isorg

10:14 pm on Apr 11, 2005 (gmt 0)

10+ Year Member



I have been looking through my HTML, and noticed that a lot of my tables have got a cellspacing=0 cellpadding=0 border=0 in them. This is because different browsers render the default values differently and so I got into the habit (many years ago) of specifying the values explicitly.

Then came along doctype definitions (I use 4.01 Transitional) and I still used to include these default values. Now I am using CSS & stylesheets, but have so far stuck with what I know, and kept specifying these values.

Is it still necessary - if you are using a doctype and CSS stylesheets - to specify a table's cellspacing, cellpadding and border each and every time? Or is there a cross-browser compatible simpler way of doing it via the stylesheet?

indiana_01

12:01 pm on Apr 12, 2005 (gmt 0)

10+ Year Member



Something like this should have the same effect...

td {
padding: 0;
margin: 0;
border: 0;
}
table {
border: 0;
}

Alternative Future

12:06 pm on Apr 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



td {
padding: 0;
margin: 0;
border: 0;
}
table {
border: 0;
}

How far back in browser version history will this work for?
And will including cellpadding=5 cellspacing=0 override the style settings?

-George

isorg

2:28 pm on Apr 12, 2005 (gmt 0)

10+ Year Member



I am not finding that this actually works! I still have to use cellspacing=0 and cellpadding=0 to get the borders of the cells to collapse completely. Am I doing something wrong maybe?

encyclo

2:55 pm on Apr 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can try adding
border-collapse:collapse;
to the
table
rule. However, if you want maximun cross-browser compatibility you should stick to using the
cellpadding="0" cellspacing="0"
- it remains valid for all HTML/XHTML versions including strict as those attributes are not really fully replaced by CSS.