如何只选择表的第一个colgroup的第一个td?

时间:2010-05-12 09:41:55

标签: css

如何只选择td的{​​{1}}的第一个colgroup?如果我有{5}列table且使用5 table

1 个答案:

答案 0 :(得分:17)

table colgroup:first-child td:first-child

来自w3schools

  

注意:要让:first-child在IE中工作,必须声明<!DOCTYPE>

<强>更新

正如DisgruntledGoat正确提到的那样,td元素不是colgroup元素的后代。但第一个colgroup显然总是包含第一列,所以

table tr td:first-child

选择每行中的第一个td,应该这样做。