Через :nth-child
li:nth-child(odd) { background: #f7f7f7; }
li:nth-child(even) { background: #fff; }
li:nth-child(2n+1) { }
li:nth-child(2n) { }
Учитывайте: nth-child считает все дети родителя; если между li есть другие узлы — индексы съедут. Для только одного типа — :nth-of-type(odd).
tr:nth-of-type(even) { background: #f0f0f0; }
Итог
odd/even или 2n/2n+1. Для zebra-таблиц часто nth-of-type, чтобы не ломаться о лишние элементы.