<th>
<th> Tag
The <th> element in HTML represents a header cell within a table. It is placed inside a <tr> row and serves as a label for the corresponding columns or rows. By default, browsers render the content inside a <th> tag as bold and centered, though these styles can be modified using CSS.
Syntax
<th>Header Content</th>
<th> Demo
If you need a table cell to act as a header, use the <th> tag instead of the <td> tag.
| ID | Name | Department |
|---|---|---|
| 001 | John Doe | IT |
| Total Employees: 1 | ||
<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Department</th>
</tr>
</thead>
<tbody>
<tr>
<td>001</td>
<td>John Doe</td>
<td>IT</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="3">Total Employees: 1</td>
</tr>
</tfoot>
</table>
<th> tag is used for table headers.Attributes
abbr (HTML5, obsolete): Previously used for a short description of the cell’s content. Instead, use thetitleattribute for accessibility.align (Deprecated in HTML5): Controlled horizontal alignment of text within the cell:left: Aligns text to the left.center: Centers the content.right: Aligns text to the right.justify: Expands text to fit the cell.char: Aligns text based on a specific character usingcharandcharoffattributes.
Related Elements
Other HTML elements for working with tables:
<caption><col><colgroup><table><tbody><td><tfoot><thead><tr>.
Conclusion
The <th> tag in HTML defines a header cell in a table, typically used in the <thead> section to label columns or rows. By default, content inside a <th> tag is bold and centered. Deprecated attributes like align should be replaced with CSS for styling, and the abbr attribute is no longer recommended for short descriptions.