Zebra-Striped List Template

Improve the readability of long or dense lists with classic alternating row colors.

This "zebra-striping" technique makes it easier for the human eye to scan across rows without losing their place.

A list of items with alternating light and dark background colors for each row.

Get Source Code Preview

About this Template

This component uses the handy CSS :nth-child() pseudo-class to apply different styles to alternating list items. It's built on a semantic unordered list and uses Flexbox to create a simple two-column layout within each row, making it ideal for presenting key-value pairs or item-and-status information. This is a purely CSS-driven effect that is simple to implement and highly effective.

Features

Code Breakdown

The structure is a simple unordered list, ul, with the class .zebra-list. Inside each list item, li, a flexbox container with display: flex and justify-content: space-between is used to push the item name and its corresponding value to opposite ends of the row.

The key to the zebra-striping effect is this CSS selector: .zebra-list li:nth-child(odd). This targets every odd-numbered list item (the 1st, 3rd, 5th, etc.) and applies a different background color to it. The rest of the list items (the even ones) retain the default background color, creating the striped pattern.

Code

Here's the full code for the template:

View Output