Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bgcolor for alternative rows in a table dynamically using CSS

How to give two different bgcolor for alternative rows in a table dynamically using CSS.

I don't want to use jQuery for solving this problem.

like image 260
ѕтƒ Avatar asked Nov 19 '12 06:11

ѕтƒ


1 Answers

Use :nth-child() pseudo class

tr:nth-child(odd){
    background-color:green
}
tr:nth-child(even){
    background-color:yellow
}​

DEMO

Here is few more selector example.

like image 75
Sowmya Avatar answered Oct 16 '22 18:10

Sowmya