2013-05-17 12:58, dorayme wrote:
> The styling achievable reliably via the COL element is known to be
> restricted to a few things, I think BORDER, BACKGROUND, WIDTH at
> least, maybe not much more.
Yes, the point is that you can assign a class to COL and use that class
in CSS, but most properties you set on COL that way have no effect. CSS
is very liberal in a sense: all elements have all properties, and you
can thus set any property on any element, but not all properties affect
all elements. The issue with COL is that it has no children. A table
cell is never a child of a COL, always a a child of a TR.
CSS 2.1 explicitly specifies that only border, background, width, and
visibility properties apply to columns:
http://www.w3.org/TR/CSS2/tables.html#columns
> Not that it might be so helpful generally but in your particular case
>
> tr td:first-child + td {text-align:center;}
> tr td:first-child + td + td + td {text-align:center;}
>
> should make the second table work by the lever of styling in the head
> without adding classes or IDs
Yes, and if you keep the current CSS code that sets text-align on COL
elements, things work on old versions of IE, too. They don't understand
the fancy selectors above, but in compensation, they incorrectly make
cells of a column aligned according to the text-align property set on
COL (this violates the specs, but here it's what we want).
You could simplify the selectors to td:nth-child(2) and td:nth-child(4),
but then you would have a problem with IE 8 (partly solvable e.g. with
Selectivizr.js, but perhaps it's better to use the clumsier selectors,
unless you are styling the 13th column or something).
--
Yucca,
http://www.cs.tut.fi/~jkorpela/