JSFiddle - React, Tailwind, and code Playground

HTML

<div>
  <p class="p">0</p>
  <div>
    <p>1</p>
    <p>2</p>
    <p>3</p>
  </div>
  <p class="p">4</p>
  <p class="p">5</p>
  <p class="p">6</p>
</div>

CSS

div > .p:nth-of-type(odd) {
  background-color: red;
}

div > .p:nth-of-type(even) {
  background-color: green;
}