th
Definition and Usage
The <th> tag defines a header cell in an HTML table or table header within a table. The HTML <th> tag defines a header cell that can appear in the first row of an HTML table. The HTML<th>
element defines a cell as header of a group of table cells. The exact nature of this group is defined by the scope and header attributes. The <th>
tag accepts the following attributes. Try adding some to the above example to see how it affects the display/behavior of the element.
The HTML <th>
tag is used for specifying a header cell (or table header) within a table.
This tag must be nested inside a <tr> tag, which in turn must also be nested correctly. You can find out more by viewing the <table> tag specifications.
Also see the <td> tag for declaring table data.
The HTML <th>
tag represents a header cell within an HTML <table>
The basic tag is written like this <th>
</th>
with the header text inserted between the opening and closing tags.
The <th>
tag must be nested inside a <tr> tag, which must also be nested correctly.
Also see the <td> tag for a normal (i.e. non-header) table cell.
An HTML table has two kinds of cells:
Header cells - contains header information (created with the <th> element)
Standard cells - contains data (created with the <td> element)
The text in <th> elements are bold and centered by default.
The text in <td> elements are regular and left-aligned by default.
Syntax
<body> <table> <tr> <th></th> ... more header cells as needed ... </tr> <tr> <td></td> ... more standard cells as needed ... </tr> ... more rows as needed ... </table> </body>