HTML <tr> Tag


Exemplo

Uma tabela HTML simples com três linhas; uma linha de cabeçalho e duas linhas de dados:

<table>
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$80</td>
  </tr>
</table>

Mais exemplos de "Experimente você mesmo" abaixo.


Definição e uso

A <tr>tag define uma linha em uma tabela HTML.

Um <tr>elemento contém um ou mais elementos <th> ou <td> .


Suporte ao navegador

Element
<tr> Yes Yes Yes Yes Yes

Atributos Globais

A <tr>tag também suporta os Atributos Globais em HTML .


Atributos do evento

A <tr>tag também suporta os atributos de evento em HTML .



Mais exemplos

Exemplo

Como alinhar conteúdo dentro de <tr> (com CSS):

<table style="width:100%">
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr style="text-align:right">
    <td>January</td>
    <td>$100</td>
  </tr>
</table>

Exemplo

Como adicionar cor de fundo a uma linha da tabela (com CSS):

<table>
  <tr style="background-color:#FF0000">
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
 </table>

Exemplo

Como alinhar o conteúdo verticalmente dentro de <tr> (com CSS):

<table style="height:200px">
  <tr  style="vertical-align:top">
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr style="vertical-align:bottom">
    <td>January</td>
    <td>$100</td>
  </tr>
</table>

Exemplo

Como criar cabeçalhos de tabela:

<table>
  <tr>
    <th>Name</th>
    <th>Email</th>
    <th>Phone</th>
  </tr>
  <tr>
    <td>John Doe</td>
    <td>[email protected]</td>
    <td>123-45-678</td>
  </tr>
</table>

Exemplo

Como criar uma tabela com uma legenda:

<table>
  <caption>Monthly savings</caption>
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$80</td>
  </tr>
</table>

Exemplo

Como definir células de tabela que abrangem mais de uma linha ou uma coluna:

<table>
  <tr>
    <th>Name</th>
    <th>Email</th>
    <th colspan="2">Phone</th>
  </tr>
  <tr>
    <td>John Doe</td>
    <td>[email protected]</td>
    <td>123-45-678</td>
    <td>212-00-546</td>
  </tr>
</table>

Páginas relacionadas

Tutorial HTML: Tabelas HTML

Referência HTML DOM: objeto TableRow

Tutorial CSS: Estilizando Tabelas


Configurações padrão de CSS

A maioria dos navegadores exibirá o <tr>elemento com os seguintes valores padrão:

tr {
  display: table-row;
  vertical-align: inherit;
  border-color: inherit;
}