CSS Table Style

Table Padding

To control the space between the border and the content in a table, use the padding property on <td> and <th> elements:

Example

Output :

Horizontal Dividers

Add the border-bottom property to <th> and <td> for horizontal dividers:

Example

Output :

Hoverable Table

Use the :hover selector on <tr> to highlight table rows on mouse over:

Example

Output :

Striped Tables

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

Example

Output :

Table Color

The example below specifies the background color and text color of <th> elements:

Example

Output :