🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to CSS Notes
Topic #63

Table Styling


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 CodingNow 2.0'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 CodingNow 2.0 explains Table Styling in CSS — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every CSS topic on CodingNow 2.0, 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 CodingNow 2.0'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 CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now