Atributo de cabeçalhos HTML


Definição e uso

O headersatributo especifica uma ou mais células de cabeçalho às quais uma célula da tabela está relacionada.


Aplica-se a

O headersatributo pode ser usado nos seguintes elementos:

Elementos Atributo
<td> cabeçalhos
<th> cabeçalhos

Exemplos

Exemplo de Td

Especifique o elemento <th> ao qual cada elemento <td> está relacionado:

<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">John Doe</td>
    <td headers="email">[email protected]</td>
    <td headers="phone">+45342323</td>
    <td headers="addr">Rosevn 56,4300 Sandnes,Norway</td>
  </tr>
</table>

Th Exemplo

Especifique o elemento <th> ao qual cada célula de cabeçalho está relacionada:

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

Suporte ao navegador

O headersatributo tem o seguinte suporte do navegador para cada elemento:

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