How can I select all tr
elements except the first tr
in a table with CSS?
I tried using this method, but found that it did not work.
How can I select all tr
elements except the first tr
in a table with CSS?
I tried using this method, but found that it did not work.
Though the question has a decent answer already, I just want to stress that the
:first-child
tag goes on the item type that represents the children.For example, in the code:
If you want to affect only the second two elements with a margin, but not the first, you would do:
that is, since the
input
s are the children, you would placefirst-child
on the input portion of the selector.Since
tr:not(:first-child)
is not supported by IE 6, 7, 8. You can use the help of jQuery. You may find it hereYou could also use a pseudo class selector in your CSS like this:
That will not apply the class to the first element with the class .desc.
Here's a JSFiddle with an example: http://jsfiddle.net/YYTFT/, and this is a good source to explain pseudo class selectors: http://css-tricks.com/pseudo-class-selectors/
Another option: