Prev: Float
Next: Tabs Using CSS1
From: dorayme on
In article
<ad76b5e1-6b97-4dd3-b272-26c4c1874dc1(a)i9g2000yqi.googlegroups.com
>,
shapper <mdmoura(a)gmail.com> wrote:

> Hello,
>
> I have a table as follows:
>
> <table class="Protocol" cellpadding="0" cellspacing="0">
>
> Can I move the cellpadding="0" cellspacing="0" to the Protocol Css
> Class?
>
> How can I do that in CSS?
>

You can do the following and it works to achieve what you want in
most good modern browsers:

1. Style the table element as border-collapse: collapse;

2. Style td and th (if latter is used) as margin:0; padding:0;

In my old Mac IE 5, it does not quite like this. Like an old car
that likes lead in its fuel. The HTML attribute of cellpadding
and cellspacing is best left in for such browsers but who uses
such old browsers, almost no one. I can't remember but I think
most of the latest Windows IEs will be fine with the CSS but we
should recheck.

In my view, it is not wrong to use *these* particular HTML
attributes and I sometimes do if there is just one table.
(Perhaps for that old fashioned retro feel of it all...) The main
advantage of the CSS way is where you have lots of tables, the
markup gets to look much cleaner with the needed instructions
hived off to the CSS sheet and can be changed, as per usual, with
multiple effects on all the tables.

--
dorayme
From: Ben C on
On 2010-05-06, shapper <mdmoura(a)gmail.com> wrote:
> Hello,
>
> I have a table as follows:
>
><table class="Protocol" cellpadding="0" cellspacing="0">
>
> Can I move the cellpadding="0" cellspacing="0" to the Protocol Css
> Class?
>
> How can I do that in CSS?

border-spacing is the CSS name for cellspacing, and cellpadding is just
padding on the cells.

So it would be padding: 0; border-spacing: 0;
From: Thomas 'PointedEars' Lahn on
Johannes Koch wrote:

> shapper schrieb:
>> I have a table as follows:
>>
>> <table class="Protocol" cellpadding="0" cellspacing="0">
>>
>> Can I move the cellpadding="0" cellspacing="0" to the Protocol Css
>> Class?
>>
>> How can I do that in CSS?
>
> table {
> border-collapse: collapse

You can have no spacing between the cells (as with cellspacing="0") without
collapsing the borders. Necessary is only

border-spacing: 0;

Everything else depends.

> }
> th, td {
> padding: 0
> }
>


PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
From: Jukka K. Korpela on
Thomas 'PointedEars' Lahn wrote:

> You can have no spacing between the cells (as with cellspacing="0")
> without collapsing the borders. Necessary is only
>
> border-spacing: 0;

How often do you want to get rid of spacing without collapsing borders? Any
example of a page of yours where you have found that useful?

Besides, you forgot to mention, or to check, that IE does not support the
property except from version 8 (and only in "standards" mode there). So in
practical authoring for the WWW, how useful is it?

--
Yucca, http://www.cs.tut.fi/~jkorpela/

From: Thomas 'PointedEars' Lahn on
Jukka K. Korpela wrote:

> Thomas 'PointedEars' Lahn wrote:
>> You can have no spacing between the cells (as with cellspacing="0")
>> without collapsing the borders. Necessary is only
>>
>> border-spacing: 0;
>
> How often do you want to get rid of spacing without collapsing borders?
> Any example of a page of yours where you have found that useful?

Mu.

> Besides, you forgot to mention, or to check, that IE does not support the
> property except from version 8 (and only in "standards" mode there).

No, I was aware of that. (Which part of "Everything else depends." did you
not get?) However, the fact remains that Johannes' solution addresses a
different problem.

> So in practical authoring for the WWW, how useful is it?

Non sequitur. Using `border-spacing: 0' for standards-compliant UAs does
not preclude applying the fallback if and when necessary.


PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
First  |  Prev  |  Next  |  Last
Pages: 1 2 3
Prev: Float
Next: Tabs Using CSS1