webdevlinux - logo Web Dev Linux

HTML Table headings

In HTML tables, you can also use Table headings. We use table headings both of vertically & horizontally.

HTML Table headings table heading element

Try the example below which demonstrates how to use horizontal headings as the column names.

FILE : table-headings.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Table Headings</title>
</head>
<body>
<table border="1">
	<tr>
		<th>Time</th>	
		<th>Week days</th>	
		<th>Saturday</th>	
		<th>Sunday</th>	
	</tr>
	<tr>
		<td>20:00-22:00</td>
		<td>Sleep</td>
		<td>Watch TV</td>
		<td>Watch TV</td>
	</tr>
	<tr>
		<td>22:00-00:00</td>
		<td>Sleep</td>
		<td>Watch a Movie</td>
		<td>Sleep</td>
	</tr>
</table>
</body>
</html>

Explanation

Take a look at the explanation of elements used in the example.

<th></th>
The th element is used to define a table heading. This can be used inside the tr element.