Home / CSS Tips Generated By ChatGPT / Styling Even and Odd Elements in CSS Select even and odd elements using the :nth-child pseudo-class for alternating styles, such as in lists or table rows. Source Code li:nth-child(even) { background-color: #f2f2f2; } li:nth-child(odd) { background-color: #ffffff; }