I have a list of elements to wich I want to add a different color depending on the even/odd BUT only elements with a special class.
<!DOCTYPE html>
<html>
<head>
<style>
p.class:nth-of-type(odd) {
background: #ff0000 ;
}
p.class:nth-of-type(even) {
background: #0000ff ;
}
</style>
</head>
<body>
<p class="class">The first paragraph.</p>
<p>The second paragraph.</p>
<p class="class">The third paragraph.</p>
<p class="class">The fourth paragraph.</p>
</body>
</html>
The result I expect is :
- red
- normal
- blue
- red
But the real result is :
- red
- normal
- red
- blue
Thanks for your answers.