How to create a zebra striped table with CSS?

Technology CommunityCategory: CSSHow to create a zebra striped table with CSS?
VietMX Staff asked 3 years ago

To create a zebra-striped table, use the nth-child() selector and add a background-color to all even (or odd) table rows:

tr:nth-child(even) {
    background-color: #f2f2f2
}