HTML th tag

HTML th element defines a header cell in the heading section of a table.

<table class="demoTable">
 <caption>The top populated countries</caption>
  <tr>
   <th>Countries</th>
   <th>Population</th>
   <th>Area</th>
   <th>Capital</th>
  </tr>
 
 <tr>
  <td> Philippines </td>
  <td> 104,918,090 </td>
  <td> 300,000 </td>
  <td> Manila </td>
 </tr>
		
 <tr>
  <td> Mexico </td>
  <td> 129,163,276 </td>
  <td> 1,964,375 </td>
  <td> Mexico City </td>
 </tr>
		
</table>
</>
The top populated countries
Countries Population Area Capital
Philippines 104,918,090 300,000 Manila
Mexico 129,163,276 1,964,375 Mexico City

table heading is very necessary because it tells us what kind of data is present in the columns.

A table heading can contain more than one rows and more than one columns.

table headings may have abbreviated form of the headings in the abbr attribute.

Tag omission

End tag (</th>) may be omitted.

Global Attributes

All the global attributes are applicable on the th element.

Global Attributes

All the global attributes are applicable on a element.

Tag Attributes

Attributes that are applicable to <th> tag
colspan

represents more than one columns for one cell.

<table><tr> <th colspan="an integer">....</th> </tr></table>
rowspan

represents more than one rows for one cell.

<table><tr> <th rowspan="an integer">....</th> </tr></table>
abbr

represents alternative text in short or expanded form for the header cell.

<table><tr> <th abbr="HS"> Heading Section </th> </tr></table>


Was this article helpful?