Last Updated: January 19, 2021
·
2.123K
· andreia

Zebra table using only CSS3

tr:nth-child(2n+1){ background: ‪#fff‬ } 
tr:nth-child(2n+0){ background: ‪#ffffec‬ }

2 Responses
Add your response

I believe you can also use :nth-chilld(even) and :nth-child(odd). :)

over 1 year ago ·

You don't need two nth-child selectors, just give the default style to the original tr element. If you want to do every other row starting with the second, 2n or even is sufficient.

over 1 year ago ·