CSS Table@ Shwetank education.com
Definition -
HTML table can be greatly improved with CSS.
Table Borders
To specify table borders in CSS, use the border property.
Example
table, th, td
{
border: 1px solid black;
}
Table Width
and Height
Example
table
{
width 200%;
}
th
{
height:50px;
}
Table Text Alignment
The text-align property sets the horizontal alignment, like left, right, or center
Example
td
{
text-align:top;
}
Table Color
The example below specifies the color of the borders, and the text and background color of th elements:
Example
<html>
<head>
<style type="text/css">
table, td, th
{
border:1px solid green;
}
th
{
background-color:green;
color:white;
}
</style>
</head>
<body>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>Shwetank</td>
<td>Gupta</td>
</tr>
<tr>
<td>Shagun</td>
<td>sharma</td>
</tr>
</table>
</body>
</html>
Output
Try it yourself?