HTML CSS examples for CSS Selector:nth-child
Style alternate rows with different color
<html lang="en"> <head> <title>Some Title</title> <style type="text/css"> .table {<!-- www. j a va 2 s .com--> width:301px; } .table span { display:inline-block; width:31%; border:2px solid Chartreuse; } .row:nth-child(odd) { background-color:yellow; } .row:nth-child(even) { background-color:blue; } </style> </head> <body> <div class="table"> <div class="row"> <span>stuff</span> <span>stuff</span> <span>stuff</span> </div> <div class="row"> <span>stuff</span> <span>stuff</span> <span>stuff</span> </div> <div class="row"> <span>stuff</span> <span>stuff</span> <span>stuff</span> </div> <div class="row"> <span>stuff</span> <span>stuff</span> <span>stuff</span> </div> </div> </body> </html>