Back to CSS Notes
Topic #63

Table Styling

Table styling recipes — striped rows, hover effects, dividers — turn data grids into polished reports. These patterns appear in every dashboard.


CSS Table Padding

To add some more space between the inner borders and the content in a table, use the padding property on and elements:

First Name Last Name Savings
Peter Griffin $100
Lois Griffin $150
Joe Swanson $300

Example

th, td
{

padding: 10px;
  text-align: left;

}

CSS Horizontal Dividers

To create horizontal dividers for a table, add the border-bottom property to and elements:

First Name Last Name Savings
Peter Griffin $100
Lois Griffin $150
Joe Swanson $300

Example

th, td {
  border-bottom: 1px solid #ddd;
}

CSS Hoverable Table

Use the CSS :hover selector on to highlight table rows on mouse over:

First Name Last Name Savings
Peter Griffin $100
Lois Griffin $150
Joe Swanson $300

Example

tr:hover {background-color: coral;}

CSS Zebra-striped Table

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

First Name Last Name Savings
Peter Griffin $100
Lois Griffin $150
Joe Swanson $300

Example

tr:nth-child(even) {background-color: #f2f2f2;}

CSS Table Color

The example below specifies a background color and a text color for the elements:

First Name Last Name Savings
Peter Griffin $100
Lois Griffin $150
Joe Swanson $300

Example

th {
  background-color: #04AA6D;
  color: white;
}

Want to go beyond the notes?

Join Coding Now Tech Institute's CSS course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Table Styling – FAQs

Quick answers about learning Table Styling in CSS.

This free note from Coding Now Tech Institute explains Table Styling in CSS — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every CSS topic on Coding Now Tech Institute, including Table Styling, is 100% free with no signup required.
With focused practice, most students grasp Table Styling in 1–3 days from these notes; pairing it with Coding Now Tech Institute's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the Coding Now Tech Institute Community (/community) — expert instructors answer within 24 hours.
Call NowEnroll Now