tags:

views:

44

answers:

1

how to select only first td of first colgroup of table? if i have table with 5 column and using 5 colgroup?

+2  A: 

table colgroup:first-child td:first-child

From w3schools:

Note: For :first-child to 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
Why the downvote? How can I improve my answer?
Felix Kling
Did this actually work? Table cells are not actually descendants of colgroup tags, they are only descendants of rows.
DisgruntledGoat
@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