RE: Styling table columns--why so limited?

> [Original Message]
> From: Dan Delaney <dan1@fluidmind.org>
> To: <www-style@w3.org>
> Date: 3/29/2004 6:06:24 PM
> Subject: Styling table columns--why so limited?
>
>
> Could someone please point me to a discussion of the rationale 
> behind such limited style options for the colgroup and col elements? 
> I'd like to know why the spec doesn't allow for something as 
> important as "text-align" and other styles on those elements.

It's fairly simple. First of all, what text is there to be aligned?
In HTML neither <COL> nor <COLGROUP> has text.  Because
inheritance works only from parents, a table cell can't inherit
from the column or the column group element unless inheritance
is fundamentally changed in a way that would make it far less
efficient.

However, not all is lost.  If you don't make use of the colspan
attribute in HTML, you can style columns using the :nth-child()
and related pseudo-classes.  tbody>tr>:nth-child(odd)
can be used to select the cells in every other column of a
table that did not use colspan for any of the cells in the body
of the table.

Unfortunately, neither Gecko nor IE supports this yet.
You can use the + combinator to approximate the missing
:nth-child in Gecko (and if you are trying to style just the first
or the last column :first-child and :last-child are available.)
IE will let you attach style to the <col> and <colgroup>
elements which the cells will inherit, but that in part is
because IE doesn't use CSS to determine what is a table
part, so determining which column a cell is in is much simpler,
altho less flexible.

Received on Monday, 29 March 2004 20:14:44 UTC