There are a lot of times where you will want to automatically style every other element slightly differently, for example, in a table, to make it more legible. Hereโs how.
tr {
background:#eee;
}
tr:nth-child(odd) {
background:#ddd;
}
The :nth-child(odd) property will target every other item of the element you have selected. Here is a working sample.