table header


The td and th elements define the headers attribute, which can be used to make tables easier to process with screen readers and other technology.


The value of the headers attribute is the ID attribute value of one or more th cells.


	      	<!DOCTYPE HTML>
			<html>
			<head>
			<style>
				thead th, tfoot th {
				text-align: left;
				background: grey;
				color: white
				}
				tbody th {
				text-align: right;
				background: lightgrey;
				color: grey
				}
				thead [colspan], tfoot [colspan] {
				text-align: center;
				}
			</style>
			</head>
			<body>
				<table>
					<thead>
						<tr>
							<th id="rank">Rank</th>
							<th id="name">Name</th>
							<th id="color">Color</th>
							<th id="sizeAndVotes" colspan="2">Size & Votes</th>
						</tr>
					</thead>
				<tbody>
					<tr>
						<th id="first" headers="rank">Favorite:</th>
						<td headers="name first">XML</td>
						<td headers="color first">HTML</td>
						<td headers="sizeAndVote first">CSS</td>
						<td headers="sizeAndVote first">ABC</td>
					</tr>
					<tr>
						<th id="second" headers="rank">2nd Favorite:
						<td headers="name second">Empty
						<td headers="color second">XYZ
						<td headers="sizeAndVote second">ABC
						<td headers="sizeAndVote second">A/td>
					</tr>
				</tbody>
					<tfoot>
						<tr>
							<th colspan="5">© 2018 studentsempire.com</th>
						</tr>
				</tfoot>
			   </table>
			</body>
			</html>
	      

The global id attribute is added to the th elements in the thead and the th elements in the tbody .


For each td and th in the tbody , the headers attribute is associates the cell with the column header.