CSS code:

Test it Now

Output:

CSS table even and odd
Next TopicCSS Box Model




CSS Table

We can apply style on HTML tables for better look and feel. There are some CSS properties that are widely used in designing table using CSS:

  • border
  • border-collapse
  • padding
  • width
  • height
  • text-align
  • color
  • background-color

CSS Table Border

We can set border for the table, th and td tags using the CSS border property.

Test it Now

Output:

      
First_Name Last_Name Marks
Sonoo Jaiswal 60
James William 80
Swati Sironi 82
Chetna Singh 72

CSS Table Border Collapse

By the help of border-collapse property, we can collapse all borders in one border only.

Test it Now

Output:

      
Name Last Name Marks
Sonoo Jaiswal 60
James William 80
Swati Sironi 82
Chetna Singh 72

CSS Table Padding

We can specify padding for table header and table data using the CSS padding property.

Test it Now

Output:

      
Name Last Name Marks
Sonoo Jaiswal 60
James William 80
Swati Sironi 82
Chetna Singh 72

CSS Table: Styling even and odd cells

We can style even and odd table cells for better look and feel. In this code, we are displaying different background colors on even and odd cells. Moreover, we have changed the background-color and color of

tag.

Contact US

Email:[email protected]

CSS Table
10/30