Choosing every second level in CSS

How can you choose every second level is the infinite level stack using only CSS?

Code example:

<div> 1 <div> 2 <div> 3 <div> 4 <div> 5 <div> [...] </div> </div> </div> </div> </div> </div> 

A visual example of a preferred result:

enter image description here

Note: JavaScript is not required; no problem when the number of levels is known.

+6
source share
2 answers

While there is no problem when the number of levels is known, when it is unknown, then it becomes impossible only with CSS, even if you can bind the top div to another element using a selector.

+4
source

What about another tag, such as span for the second level and target, which is in the CSS div markup.

What creates this endless iteration?

+1
source

All Articles