nth-child of

by cambraca

HTML

<ul>
<li>One</li>
<li>Two</li>
<li class="hidden">Three</li>
<li>Four</li>
<li>Five</li>
<li>Six</li>
<li>Seven</li>
</ul>

CSS

li:nth-child(2n of :not(.hidden)) {
  background-color: lightgrey;
}

li.hidden {
  display: none;
}