in

CSS – Styling Every Other Element

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.

See the Pen CSS – Every Other Item Style by Nicholas Coughlin (@nicholascoughlin) on CodePen.

css3

Building A CSS Grid Without “display: grid” Or “display: flex;”

Terminal Commands Reference