Add table header wrapper with thead element
Description
The thead
element defines one or more rows
that are the column labels for a table
element.
Without the thead
element, all of your tr elements are
assumed to belong to the body of the table.
The align, char, charoff
, and valign attributes are obsolete.
Example
The following code shows the addition of the thead
element to the example table.
<!DOCTYPE HTML>
<html>
<head>
<style>
thead th {<!--from w w w . j av a2 s .co m-->
text-align: left;
background: grey;
color: white
}
tbody th {
text-align: right;
background: lightgrey;
color: grey
}
</style>
</head>
<body>
<table>
<thead>
<tr>
<th>A</th>
<th>B</th>
<th>C</th>
<th>D</th>
</tr>
</thead>
<tbody>
<tr>
<th>Favorite:</th>
<td>XML</td>
<td>HTML</td>
<td>CSS</td>
</tr>
<tr>
<th>2nd Favorite:</th>
<td>Java</td>
<td>Javascript</td>
<td>Oracle</td>
</tr>
<tr>
<th>3rd Favorite:</th>
<td>C#</td>
<td>MySQL</td>
<td>PHP</td>
</tr>
</tbody>
</table>
</body>
</html>