Re: styles in col & colspan elements

Nicholas Shanks wrote:
> 
> Hey all,
> I don't know if this is just a lack of implementation or I'm 
> misunderstanding the specifications, but are the col and colspan 
> elements special with regards to what styles they accept?

Very much so. Only 4 properties, currently, are defined to work:
     http://www.w3.org/TR/CSS21/tables.html#q4

> Surly any style which works on a td or tbody element should work on the 
> columns too!

I would have to say Ian Hickson's weblog entry entitled "The mystery of 
why only four properties apply to table columns" provides a good insight 
into this situation and the problems, though there are a number of other 
accounts of this (probably all in the archives of this list somewhere).
     http://ln.hixie.ch/?start=1070385285&count=1

> Some of these seem to caused by a lack of support in <td> elements for 
> the specified style, such as this:
> 
> <html><body><table border="1">
> <tr><td style="width: 40px; white-space: pre; overflow: hidden;">one two 
> three four five
> 
> Which should look something like this:
> 
> +-------------+
> | one two thr |
> +-------------+
>  |<-  40px ->|
> 
> But no browser renders that correctly either :-(

I wouldn't be surprised if the table layout method "defined" in CSS 
limits some things from working, or causes unexpected results; however, 
laying out a table (especially incrementally) is seriously hard work and 
believe current implementations have limits to what they support.

In your example, the desired effect can be achieved by using a <div> 
inside a <td> and applying the style to the div, at least in Mozilla.

> Also, is there a definition of what should happen in this case:
> 
> <html><body><table style="color: red;">
> <col style="background-color: yellow;">
> <col style="color: blue;">
> <tr><td colspan="2">some text
> 
> Are the two styles merged (which takes precedence?) or does the cell 
> only take on the styles of one column?
> (i.e. is the cell text red or blue?)
> Opera and Safari, when presented with conflicting background colours 
> take that specified by the first column. If this is not defined, should 
> it be?

See http://www.w3.org/TR/CSS21/tables.html#table-layers and 
http://www.w3.org/TR/CSS21/tables.html#q4 as earlier.

 From what I see, the cell will have a yellow background, since item 3 
from #table-layers says "The background extends to cover the full area 
of all cells that originate in the column, even if they span outside the 
column, but this extension does not affect background image positioning."

The text would be red, since 'color' is not a property supported on col 
and col-groups, and thus is simply inherited from the table.

-- 
James Ross <silver@warwickcompsoc.co.uk>

Received on Tuesday, 11 May 2004 18:00:06 UTC