HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Table Tags in HTML</title>
<style>
html {
font-family: sans-serif;
}
table {
border-collapse: collapse;
border: 2px solid rgb(200,200,200);
letter-spacing: 1px;
font-size: 0.8rem;
}
td, th {
border: 1px solid rgb(190,190,190);
padding: 10px 20px;
}
td {
text-align: center;
}
caption {
padding: 10px;
}
</style>
</head>
<body>
<!--
<table> : is a structured set of data made up of rows & columns
<tr> : stands for 'table row' (defines a row in an HTML table)
<td> : stands for 'table data' (a standard data cell in an HTML table)
<th> : stands for 'table header' (defines a header cell in an HTML table)
<caption> : defines a table caption. This must be inserted immediately after the <table>
<colgroup> : specifies a group of one or more columns in a table for formatting.
-->
<h1>Demo: Table Tags in HTML</h1>
<h2>Example 1: School timetable</h2>
<table>
<tr>
<td> </td>
<th>Mon</th>
<th>Tue</th>
<th>Wed</th>
<th>Thu</th>
<th>Fri</th>
<th>Sat</th>
<th>Sun</th>
</tr>
<tr>
<th>1st period</th>
<td>English</td>
<td> </td>
<td> </td>
<td>Maths</td>
<td>Physics</td>
<td> </td>
<td> </td>
</tr>
<tr>
<th>2nd period</th>
<td>English</td>
<td>English</td>
<td> </td>
<td>Maths</td>
<td>Physics</td>
<td> </td>
<td> </td>
</tr>
<tr>
<th>3rd period</th>
<td> </td>
<td>Maths</td>
<td> </td>
<td>Maths</td>
<td>Physics</td>
<td> </td>
<td> </td>
</tr>
<tr>
<th>4th period</th>
<td> </td>
<td>English</td>
<td> </td>
<td>English</td>
<td>Physics</td>
<td> </td>
<td> </td>
</tr>
</table>
<br><br><hr>
<h2>Example 2: School timetable</h2>
<table>
<caption>Sachin's weekly lesson timetable</caption>
<colgroup>
<col span="2">
<col style="background-color: lightblue;">
<col style="width:90px;">
<col style="background-color:lightblue;">
<col style="background-color: lightcoral; border:4px solid indigo;">
<col span="2" style="width:90px;">
</colgroup>
<tr>
<td> </td>
<th>Mon</th>
<th>Tue</th>
<th>Wed</th>
<th>Thu</th>
<th>Fri</th>
<th>Sat</th>
<th>Sun</th>
</tr>
<tr>
<th>1st period</th>
<td>English</td>
<td> </td>
<td> </td>
<td>Maths</td>
<td>Physics</td>
<td> </td>
<td> </td>
</tr>
<tr>
<th>2nd period</th>
<td>English</td>
<td>English</td>
<td> </td>
<td>Maths</td>
<td>Physics</td>
<td> </td>
<td> </td>
</tr>
<tr>
<th>3rd period</th>
<td> </td>
<td>Maths</td>
<td> </td>
<td>Maths</td>
<td>Physics</td>
<td> </td>
<td> </td>
</tr>
<tr>
<th>4th period</th>
<td> </td>
<td>English</td>
<td> </td>
<td>English</td>
<td>Physics</td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>