샘플 html

<div id="test-code-1">
    <ul class="ui list">
        <li class="first">Gaining Access</li>
        <li class="second">Inviting Friends</li>
        <li class="third">Benefits</li>
        <li class="fourth">Warranty</li>
    </ul>
</div>

홀수 번째 li tag 선택하기

#test-code-1 li:nth-child(even) {color: green}
  • Gaining Access
  • Inviting Friends
  • Benefits
  • Warranty

짝수 번째 li tag 선택하기

nth-child(even) = nth-child(2n)

#test-code-1 li:nth-child(odd) {color: green}
#test-code-1 li:nth-child(2n) {color: green}
  • Gaining Access
  • Inviting Friends
  • Benefits
  • Warranty