CSS CSS Tutorial CSS Advanced CSS Responsive Web Design(RWD) CSS Grid CSS Properties Sass Tutorial Sass Functions



CSS Tables

CSS Tables are a powerful tool for creating structured and organized data on a web page. They allow you to display data in a tabular format, making it easier for users to read and understand. In this tutorial, we will explore the basics of CSS Tables and how to use them effectively in your web design.

What are CSS Tables?

CSS Tables are a way to display data in a tabular format on a web page. They are similar to traditional HTML tables, but with the added benefit of being able to style them using CSS. This means that you can customize the look and feel of your tables to match the overall design of your website.

There are two main types of CSS Tables: <table> and <div> tables. The <table> element is the traditional HTML table, while the <div> table is a newer, more flexible option that allows you to create tables using div elements and CSS.

Creating a CSS Table

Creating a CSS Table is easy. You can start by creating a basic HTML table using the <table> element. Here is an example:

<table>
  <tr>
    <th>Name</th>
    <th>Age</th>
    <th>Gender</th>
  </tr>
  <tr>
    <td>John</td>
    <td>25</td>
    <td>Male</td>
  </tr>
  <tr>
    <td>Jane</td>
    <td>30</td>
    <td>Female</td>
  </tr>
</table>

This will create a basic table with three columns: Name, Age, and Gender. The first row of the table contains the column headings, while the subsequent rows contain the data.

Styling a CSS Table

Once you have created your table, you can use CSS to style it. Here are some examples:

Changing the Table Border

You can change the border of your table using the border property. Here is an example:

table {
  border: 1px solid black;
}

This will add a black border around your table.

Changing the Table Background Color

You can change the background color of your table using the background-color property. Here is an example:

table {
  background-color: #f2f2f2;
}

This will set the background color of your table to a light gray color.

Changing the Table Font

You can change the font of your table using the font-family property. Here is an example:

table {
  font-family: Arial, sans-serif;
}

This will set the font of your table to Arial or a similar sans-serif font.

Changing the Table Text Color

You can change the text color of your table using the color property. Here is an example:

table {
  color: #333;
}

This will set the text color of your table to a dark gray color.

Conclusion

CSS Tables are a powerful tool for displaying data in a structured and organized format on a web page. By using CSS to style your tables, you can customize their look and feel to match the overall design of your website. With a little bit of practice, you can create beautiful and functional tables that will enhance the user experience of your website.

References

Activity