Use the <th> tag in HTML to create a heading. The HTML <th> tag is used for specifying a header cell or table header within a table.
The following are the attributes −
| Attribute | Value | Description |
|---|---|---|
| abbr | abbreviated_text | Deprecated − Specifies an abbreviated version of the content in a header cell. |
| align | right left center justify char | Deprecated − Content alignment in header cell. |
| axis | Name | Deprecated − Specifies a category for this th. |
| bgcolor | rgb(x,x,x) #hexcode colorname | Deprecated − Specifies the background color of the header cell. |
| char | Character | Deprecated − Specifies which character to align text on. Used when align = "char" |
| charoff | pixels or % | Deprecated − Specifies an alignment offset (either in pixels or percentage value) against the first character as specified with the char attribute. Used when align = "char" |
| colspan | Number | Specifies the number of columns the header cell spans across. |
| headers | Id | Specifies one or more header cells a cell is related to. |
| height | Pixels | Deprecated − Specifies the height of the header cell. |
| nowrap | Nowrap | Deprecated − Prevents text from automatically wrapping. |
| rowspan | rowspan | Specifies the number of rows the header cell spans across. |
| scope | col colgroup row rowgroup | This attribute is used on header cells and specifies the cells that will use this header's information. |
| valign | top middle bottom baseline | Deprecated − Vertical alignment. |
| width | pixels or % | Deprecated − Specifies the width of the header cell |
Example
You can try to run the following code to learn how to create table heading in HTML −
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
}
</style>
</head>
<body>
<h3>Result</h3>
<table>
<th>Marks</th>
<th>Student</th>
<tr>
<td>600</td>
<td>Amit</td>
</tr>
<tr>
<td>400</td>
<td>Anil</td>
</tr>
</table>
</body>
</html>