Today I will be teaching you how to create a simple table using only HTML and CSS
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<table>
<tr>
<th id="col1">Month</th>
<th id="col2">Sales</th>
<th>Expenses</th>
<th>Net Income</th>
<th>Tax</th>
</tr>
<tr>
<td id="col1">Jan</td>
<td id="col2">100,000</td>
<td>50,000</td>
<td>50,000</td>
<td>10,000</td>
</tr>
<tr>
<td id="col1">Feb</td>
<td id="col2">150,000</td>
<td>75,000</td>
<td>75,000</td>
<td>15,000</td>
</tr>
<tr>
<td id="col1">Mar</td>
<td id="col2">120,000</td>
<td>60,000</td>
<td>60,000</td>
<td>12,000</td>
</tr>
<tr>
<td id="col1">April</td>
<td id="col2"> 20,000</td>
<td>20,000</td>
<td>0</td>
<td>0</td>
</tr>
</table>
</body>
</html>
CSS
body{
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background-color: #222;
}
table{
background-color: #e3e3e3;
border-collapse: collapse;
width: 55%;
text-align: center;
}
th, td{
border-bottom: 1px solid black;
}
th{
height: 50px;
background-color: #c60021;
font-size: 24px;
}
td{
height: 40px;
font-size: 20px;
}
tr:nth-child(odd){
background-color: #a6a6a6;
}
tr:hover{
background-color: rgba(0, 0, 0, 0.5);
}
If you found this blog post helpful don’t forget to check out my other projects and if you want more content follow me on
YouTube: https://www.youtube.com/channel/UC2nxqB2usQIS2c8zwVZKWEQ
Instagram: https://www.instagram.com/coding_for_the_web/
Twitter: https://twitter.com/LearnWebCoding
Comments