codegurukool.com · Free coding tutorials & online compiler

Home › CSS Tutorial › CSS tables

CSS tables

Make tables readable.

Use border-collapse, padding, and :nth-child(even) for striped rows.

Example code

<style>
table{border-collapse:collapse;width:100%}
th,td{padding:8px;border-bottom:1px solid #ccc;text-align:left}
tr:nth-child(even){background:#f0f4f8}th{background:#14213d;color:#fff}
</style>
<table><tr><th>Name</th><th>Role</th></tr><tr><td>Ann</td><td>Dev</td></tr><tr><td>Raj</td><td>Design</td></tr></table>

Run this code in the online editor

← CSS listsCSS display →