Roedy Green wrote:
The only browser I have encountered that supports
<colgroup><co l class="behold"> </colgroup>
to apply a CSS style to a whole column, is Microsoft Internet
Explorer. I have been told it SHOULD NOT do so, since this is not
part of the specification.
As someone who is capable of understanding specs, and has discussed some
of these issues, there are actually a few elements that apply: border,
background, width, and visibility. There is actually a wonderful post by
Hixie that explains why this arrangement makes sense.
How then to you apply styles to entire columns? Surely you don't have
to write
You have several choices. The first thing to keep in mind that most of
the below will fail if you use colspan=""; David Baron (a key Mozilla
layout developer) has proposed the :nth-column() attribute which would
do the right thing in a better way, but nothing has come of it yet.
Choice #1 (supported by Opera, Safari, and alpha builds of Firefox 3.1):
td:nth-child(3) { /* etc */ }
Choice #2 (supported by IE 7, Opera, Safari, and Firefox):
td:first-child + td + td { /* etc */ }
Choice #3 (supported by all browsers) (works with colspan):
<td class="behold"o n every row item.
Addendum:
IE 8 does not appear to claim to support :nth-child, but don't hold me
to that. Firefox 3.1 (IIRC) should be released in Q1 or Q2 2009. Support
for :nth-child was added there (IIRC) just after the release of 3.0, so
any Firefox 3.1 nightly should have support for :nth-child.
--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth