HTML <th> tag
The <th> tag defines the header content of the table in the HTML document.
To code the <th> tag, you should code this inside the <tr> tag. The <tr> tag defines a single row.
Syntax:
<th>text..</th>
Example
<table> <tr> <th>BIG DATA </th> <th>DIGITAL MARKETING</th> <th>MAINFRAME </th> </tr> <tr> <td>Spark</td> <td>SEO</td> <td>COBOL</td> </tr> <tr> <td>Scala</td> <td>Social Media</td> <td>DB2</td> </tr> <tr> <td>HBase</td> <td>Content</td> <td>JCL</td> </tr> </table>
Difference between HTML4.01, XHTML and HTML5
HTML4 | XHTML | HTML5 |
---|---|---|
No difference | No difference | All layout related attributes of <th> tag are deprecated in HTML5. |
Attributes used with <th> tag
Attribute | Description |
---|---|
abbr | Sets the abbreviation for the content of the header cell in the HTML Document. |
scope | To relate one header cell with other header cell using any one the values out of these - row, rowgroup, col, or colgroup. |
sorted | To set the sort direction of the header column using any one of these- number, reversed, number reversed or reversed number. |
colspan | To set how many columns the header cell will span. |
headers | Describes the header cells which are related to a particular header cell. |
rowspan | To set how many rows the header cell will span. |
align | Describes the alignment of content of the header to either left, right, justify, center, or char. (HTML5 does not support this attribute with this tag). |
axis | To Categorize the header cells to group related columns of data. (HTML5 does not support this attribute). |
bgcolor | Describes Background color of the header cell. (HTML5 does not support this attribute with this tag). |
border | Border of the cell is defined. (HTML5 does not support this attribute with this tag). |
char | Sets the alignment of the content inside the header cell to a character. The default value of char is decimal-point character. (HTML5 does not support this attribute with this tag). |
charoff | Sets the character offset i.e. the number of characters the content of the header cell will align from a particular specified character. (HTML5 does not support this attribute with this tag). |
height | Height of the header cell of the table in pixels or %. (HTML5 does not support this attribute). |
nowrap | Informs the browser that it should not wrap the content of the header cell. (HTML5 does not support this attribute with this tag). |
valign | To align the content of the header cell vertically at top, bottomp, middle, or baseline. (HTML5 does not support this attribute). |
width | Width of the header cell of the table in pixels or %. (HTML5 does not support this attribute). |
Global Attributes
The <th> tag supports Global attributes.
Event Attributes
The <th> tag supports Event attributes.
Supporting Browsers
Default CSS Values
display: table-cell;
text-align: center;
font-weight: bold;
vertical-align: inherit;
Related Tags
<table> , <tr> , <td> , <caption>, <thead> , <tfoot> , <colgroup> and <col> tags.