Make your tables striped

Excerpt

even/odd formats for text lines is best practice since long ago using colored paper.

There is more value in the in the tablesort example from day 7. When opening the page source code you can find some CSS that uses rules for even and odd rows with slightly different background colors.

.dataTab tr:nth-child(even) {
  background: #ddd
}

.dataTab tr:nth-child(odd) {
  background: #eee
}

This I have not recognized for a long time and the options in the :nth-child() selector are complex but powerfull. The keywords even and odd can also be used.

I searched multiple and therefore so I added it to my personal snippet library and now to the advent calender as well.

No need to use JavaScript for this any more. All browsers support these rules.

See also

Tags

CSS