w3resource

HTML thead tag and element

HTML thead element

1. HTML thead (table header) element defines the block of rows that consist of the column headers for an HTML table.

2. A table header starts with <thead> tag and ends with </thead> tag.

Syntax

 
<thead>
<tr>..............</tr>
</thead> 

Category

HTML thead element is a part of HTML Tables.

Whether both start and end tags are required

The start tag is required but end tag is optional.

Can contain

HTML thead element can contain inline elements.

Can reside within

HTML thead element can reside within a table element.

Attributes

Attributes specific to this element

align : Specifies the position of the caption with respect to the table.

Value Description
top Places the caption at the top of the table. Default.
right Places the caption at the right of the table.
bottom Places the caption at the bottom of the table.
left Places the caption to the left of the table.

Identifiers

id, class.

language information and text direction

lang, dir.

Title

Title.

Style

Style.

Events

onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup.

Cell alignment

align, char and charoff attributes.

Supported doctypes

HTML 4.01 Strict, HTML 4.01 Transitional, and HTML 4.01 Frameset.

Example of using HTML thead element

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>html thead tag example</title>
</head>
<body>
<table border="1">
<thead>
<tr>
<th>Student code </th>
<th>% of marks </th>
</tr>
</thead>
<tr>
<td>S001</td>
<td>85</td>
</tr>
<tr>
<td>S002</td>
<td>86</td>
</tr>
<tr>
<td>S003</td>
<td>72</td>
</tr>
<tr>
<td>S004</td>
<td>89</td>
</tr>
</table>
</body>
</html>

Result

html thead element

View this example in a separate browser window

HTML thead tag example.

Pictorial presentation

html-thead-tag

Previous: HTML caption tag and element
Next: HTML tfoot tag and element

Test your Programming skills with w3resource's quiz.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/html/thead/HTML-thead-tag-and-element.php