how to select only first td of first colgroup of table? if i have table with 5 column and using 5 colgroup?
views:
44answers:
1
+2
A:
table colgroup:first-child td:first-child
From w3schools:
Note: For
:first-childto work in IE a<!DOCTYPE>must be declared.
Update:
As DisgruntledGoat mentions correctly, td elements are not descendants of colgroup elements. But the first colgroup obviously always includes the first column so this
table tr td:first-child
which selects the first td in every row, should do it.
Felix Kling
2010-05-12 09:46:08
Why the downvote? How can I improve my answer?
Felix Kling
2010-05-12 09:56:04
Did this actually work? Table cells are not actually descendants of colgroup tags, they are only descendants of rows.
DisgruntledGoat
2010-05-14 14:02:58
@DisgruntledGoat: Now that you mention it, you are right, this should not work. Sorry for the false information, I was more concentrating on `:first-child`. But anyway the first `colgroup` always includes the first column, so it is something similar.
Felix Kling
2010-05-14 14:39:17