CSS Goody : Alternating Row Colors

This is a treat for any developer that has written complex looping code to alternate the styling of rows within a table to produce a striped result.  CSS 3 now enables you to simply apply a style to your row tags, specifying odd or even to produce the desired result.

The selector is simple:

tr:nth-child(odd) {
background-color: silver

And the result is beautiful (CSS 3 supporting browser required)

Live example of CSS3 Alternating Row Colors


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.