CSS can be used to style tables in HTML. Here are some common CSS styles for tables:
- Set border: By default, tables have no border. You can add a border to the table using the
border
property in CSS. For example:
table {
border: 1px solid black;
}
This will add a black border with a width of 1 pixel to the table.
2. Set table width: You can set the width of the table using the width
property in CSS. For example:
table {
width: 100%;
}
This will make the table take up 100% of the available width on the webpage.
3. Set table cell padding: You can set the padding of the cells in the table using the padding
property in CSS. For example:
td, th {
padding: 10px;
}
This will add 10 pixels of padding to all cells in the table.
4. Set table cell border: You can set a border for cells in the table using the border
property in CSS. For example:
td, th {
border: 1px solid black;
}
This will add a black border with a width of 1 pixel to all cells in the table.
5. Set table cell background color: You can set the background color of cells in the table using the background-color
property in CSS. For example:
td {
background-color: #f2f2f2;
}
This will set the background color of all cells in the table to a light gray color.
These are just a few examples of how you can style tables using CSS. Remember to experiment with different styles and find what works best for your website.