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.
2.1m questions
2.1m answers
60 comments
57.0k users