I'm currently developing a commenting feature, and I am in need of CSS to select every alternate child <div>
(even children nested within the first set of children).
Consider this example HTML structure:
<body>
<div class="comment">
<div class="comment"/>
<p class="something else"/>
<div class="comment">
<div class="comment"/>
<div class="comment"/>
</div>
</div>
<div class="comment"/>
<div class="comment"/>
</body>
How can I target every other <div>
within the body excluding <p>
tags?
The desired outcome should have the following pattern:
(Double asterisks signify even, single asterisk denotes odd, no asterisks indicate neither)
<body>
**<div class="comment">**
*<div class="comment"/>*
<p class="something else"/>
**<div class="comment">**
*<div class="comment"/>*
**<div class="comment"/>**
</div>
</div>
*<div class="comment"/>*
**<div class="comment"/>**
</body>
I aim to style every other <div>
systematically.
Is there a solution for achieving this?