Table Header

An HTML table contains a set of columns and actual data rows and each row consists of one or more cells, which can be either header or data cells. Header information in a table is defined with the < th > tag.

<th>Column Header</th>

The < th > element defines a header cell in a table. The < th > elements are contained within a < tr > element , which may also contain < td > elements for data cells.


HTML Source Code :

<html> <body> <table border=1> <tr> <th> Alphabets </th> <th> Numbers </th> </tr> <tr> <td> A </td> <td> 1 </td> </tr> <tr> <td> B </td> <td> 2 </td> </tr> </table> </body> </html>

Most browsers make < th > cells content centered and bold.

HTML Table Caption

A < caption > .. < caption > tag of a Table represents the title of the table, it should tell what the table is about. The caption text should be relatively short, but informative.

<caption>Table Caption</caption>

The caption element can only be used once per table and must immediately follow the table start tag.


HTML Source Code :

<html> <body > <table border=1> <caption>Table Caption</caption> <tr> <th> Alphabets </th> <th> Numbers </th> </tr> <tr> <td> A </td> <td> 1 </td> </tr> <tr> <td> B </td> <td> 2 </td> </tr> </table> </body> </html>

Captions are placed above the table by default. Captions can also be placed below, to the left, or to the right of the table, based on the value of the "align" parameter.

<caption align=bottom>Table Caption</caption>

The above HTML code display caption at the bottom of a Table.

The < caption > tag is rarely used even though all major browsers in use these days supports it.