HTML headers Attribute

Definition and Usage

The headers attribute specifies one or more header cells a table cell is related to.

Applies to

The headers attribute can be used on the following elements:

Elements Attribute
<td> headers
<th> headers

Examples

Td Example

Specify the <th> element each <td> element is related to:

<table>
<tr>
<th id="name">Name</th>
<th id="email">Email</th>
<th id="phone">Phone</th>
<th id="addr">Address</th>
</tr>
<tr>
<td headers="name">SamS</td>
<td headers="email">sam.s@lovelife.com</td>
<td headers="phone">+917209117653</td>
<td headers="addr">Gandhi Path, Ward no. - 08, Saharsa</td>
</tr>
</table>

Th Example

Specify the <th> element each header cell is related to:

<table>
<tr>
<th id="name" colspan="2">Name</th>
</tr>
<tr>
<th headers="name">Firstname</th>
<th headers="name">Lastname</th>
</tr>
</table>

Browser Support

The headers attribute has the following browser support for each element:

Element          
td Yes Yes Yes Yes Yes
th Yes Yes Yes Yes Yes

Comments