How can I style :nth-child(4n)
even with the element is nested inside a div, example here is p
inside div
:
p:nth-child(2) {
background: red;
}
<p>The first paragraph.</p>
<div>
<p>The second paragraph.</p>
</div>
<p>The third paragraph.</p>
<p>The fourth paragraph.</p>