The HTML and CSS below produce that the 1st and 4th elements get the nth-child(odd) style instead of the 1st, 3rd, 5th, ... elements.
If I continue and add additional elements with the class "one" they will be colored in the following pattern:
1st, 4th, 5th, 8th, ... and so on.
I am not sure why this is the behaviour, any alternatives that will actually work only with CSS?
.one {
background-color:yellow;
}
.two {
background-color:red;
}
.one:nth-child(odd) {
color:pink;
}
<p class="one">
First Paragraph of class one
</p>
<p class="one">
Second Paragraph of class one
</p>
<p class="two">
First Paragraph of class two
</p>
<p class="one">
Third Paragraph of class one
</p>
<p class="one">
Forth Paragraph of class one
</p>