simple table css examples is a vital skill for web developers and designers who want to create visually appealing and user-friendly tables on their websites.
In this article, we'll explore various simple table CSS examples, covering the basics, styling, and best practices to help you create stunning tables that enhance the overall user experience.
Basic Table CSS Examples
When it comes to styling tables, starting with the basics is essential. Here are some simple table CSS examples to get you started:

To style a table, you'll need to add CSS to your HTML file. Let's say you have the following HTML table:
<table>
<thead>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>John Doe</td>
<td>30</td>
</tr>
<tr>
<td>Jane Doe</td>
<td>25</td>
</tr>
</tbody>
</table>
To make this table look more appealing, you can add the following CSS:
table {
border-collapse: collapse;
width: 100%;
}
th, td {
border: 1px solid #ddd;
padding: 10px;
text-align: left;
}
th {
background-color: #f0f0f0;
}
This CSS code will give your table a basic style, including a collapsed border, padding, and a light gray background for the headers.

Styling Table Borders and Shading
Another essential aspect of table styling is controlling borders and shading. Here are some simple table CSS examples to help you achieve this:
Let's say you want to add a dark gray border to your table and a light gray shading to the headers. You can add the following CSS:
table {
border-collapse: collapse;
width: 100%;
border: 1px solid #333;
}
th, td {
border: 1px solid #ccc;
padding: 10px;
text-align: left;
}
th {
background-color: #f0f0f0;
border-bottom: 2px solid #333;
}
This CSS code will give your table a dark gray border and a light gray shading to the headers.

Adding Shadows and Gradients
To take your table styling to the next level, you can add shadows and gradients. Here are some simple table CSS examples to help you achieve this:
Let's say you want to add a drop shadow to your table and a gradient background to the headers. You can add the following CSS:
table {
border-collapse: collapse;
width: 100%;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
th, td {
border: 1px solid #ccc;
padding: 10px;
text-align: left;
}
th {
background: linear-gradient(to bottom, #f0f0f0, #cccccc);
border-bottom: 2px solid #333;
}
This CSS code will give your table a drop shadow and a gradient background to the headers.
Best Practices for Simple Table CSS Examples
When working with simple table CSS examples, here are some best practices to keep in mind:
- Use the
border-collapseproperty to control the border layout. - Use the
widthproperty to set the table width. - Use the
paddingproperty to add space between cells. - Use the
text-alignproperty to align text within cells. - Use the
background-colorproperty to set the background color of headers. - Use the
borderproperty to control cell borders. - Use the
box-shadowproperty to add a drop shadow to the table.
Common Table CSS Properties
Here's a list of common table CSS properties to help you with your simple table CSS examples:
border-collapse: controls the border layoutwidth: sets the table widthpadding: adds space between cellstext-align: aligns text within cellsbackground-color: sets the background color of headersborder: controls cell bordersbox-shadow: adds a drop shadow to the tablelinear-gradient: adds a gradient background to headers
Conclusion
Simple table CSS examples are an essential part of web design, and mastering them can help you create visually appealing and user-friendly tables on your website. By following the best practices and common table CSS properties outlined in this article, you'll be well on your way to creating stunning tables that enhance the overall user experience.






















