how i can select all tr except first tr in the table using css.
how i can select them using css
i used this method and find that first child not worked
how i can select all tr except first tr in the table using css.
how i can select them using css
i used this method and find that first child not worked
By adding a class to either the first tr
or the subsequent tr
s. There is no crossbrowser way of selecting the rows you want with CSS alone.
However, if you don't care about Internet Explorer 6, 7 or 8:
tr:not(:first-child) {
color: red;
}
ideal solution but not supported in IE
tr:not(:first-child) {css}
second solution would be to style all tr's and then override with css for first-child:
tr {css} tr:first-child {override css above}
You could create a class and use the class when you define all of your future 's that you want (or don't want) to be selected by the CSS.
This would be done by writing
<tr class="unselected">
and then in your css having the lines (and using the text-align command as an example) :
unselected {
text-align:center;
}
selected {
text-align:right;
}
sounds like the 'first line' you're talking of is your table-header - so you realy should think of using thead
and tbody
in your markup (click here) which would result in 'better' markup (semantically correct, useful for things like screenreaders) and easier, cross-browser-friendly possibilitys for css-selection (table thead ... { ... }
)
Since "tr:not(:first-child)" is not supported by IE 6, 7, 8. You can use the help of jQuery. You may find it here
Thanks