Zebra Striped and Hover Tables
Use :nth-child(even) to stripe rows and :hover to highlight the row under the pointer. It makes long tables easier to read.
Example
<style>
table { border-collapse: collapse; width: 100% }
td, th { padding: 6px 10px; text-align: left }
tr:nth-child(even) { background: #1e293b }
tr:hover { background: #134e4a }
</style>
<table><tr><th>City</th><th>Pop</th></tr><tr><td>Lagos</td><td>15M</td></tr><tr><td>Accra</td><td>2M</td></tr><tr><td>Nairobi</td><td>4M</td></tr></table>Exercise
Select even rows.
tr:nth-child()
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.