I want to zebra-stripe a html table without using any js stuff or writing server-side code to generate even/odd classes for table rows. Is it ever possible to do using raw css?
It is possible, with CSS3 selectors:
tr:nth-child(even) { background-color: red; } tr:nth-child(odd) { background-color: white; }
According to caniuse.com, every browser supports it now.
1.4m articles
1.4m replys
5 comments
57.0k users