HTML <th> tag

HTML <th> tag

The <th> tag specifies a header cell in an HTML table.

There are two kinds of cells available for an HTML table.

  • <th> (header cell) - contains column heading.
  • <td> (data cell) - contains table data.

Note: By default, the text inside the <th> element are bold and centered.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <table> <tr> <th>S.No</th> <th>Name</th> </tr> <tr> <td>1</td> <td>Brendan</td> </tr> <tr> <td>2</td> <td>Eich</td> </tr> </table> </body> </html>

Attributes

The following are the attributes of <th> tag. Also try Global attributes.

AttributeValueExplanation
abbrtextSpecifies an abbreviated description of the content in a <th> element.
colspannumberSpecifies how many columns the <th> element should extend.
headersIDContains a list of space-separated strings, each corresponding to the id attribute of the <th> elements that apply to this element.
rowspannumberSpecifies how many rows the <th> element should extend.
scope
  • row
  • col
  • rowgroup
  • colgroup
  • auto
Specifies whether a header cell is a header for a row, column, rowgroup, or colgroup.

Deprecated Attributes

The following attributes should not be used in any case.

AttributeValueExplanation
align
  • left
  • right
  • center
  • justify
  • char
Specifies the horizontal alignment of the content in a <th> element.
axisIDSpecifies a grouping of cell.
bgcolor
  • color name
  • #RRGGBB
Specifies the background color of a <th> element.
chartextSpecifies a character to align the content inside <th> element.
charoffnumberSpecifies the number of characters to offset the <th> data from the alignment characters specified by the char attribute.
heightpx / %Specifies the height of the <th> element.
valign
  • baseline
  • bottom
  • middle
  • top
Specifies the vertical alignment of the content in the <th> element.
widthpx / %Specifies the width of the <th> element.

Reminder

Hi Developers, we almost covered 99.5% of HTML Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in HTML.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Meet the Author