Etiqueta <tr> HTML
Definição e uso
<tr>
etiquetas definem linhas na tabela HTML.
<tr>
Elementos contêm uma ou mais <th> ou <td> Elemento.
Veja também:
Tutorial de HTML:Tabela HTML
Manual de Referência do DOM HTML:Objeto TableRow
Tutorial de CSS:Definir estilo de tabela
Exemplo
Exemplo 1
Uma tabela HTML simples de três linhas; uma linha de título e duas linhas de dados:
<table> <tr> <th>Mês</th> <th>A poupança</th> </tr> <tr> <td> Janeiro</td> <td>¥3400</td> </tr> <tr> <td> Fevereiro</td> <td>¥4500</td> </tr> </table>
Exemplo 2
Como alinhar: <tr>
do conteúdo (usando CSS):
<table style="width:100%"> <tr> <th>Mês</th> <th>A poupança</th> </tr> <tr style="text-align:right"> <td> Janeiro</td> <td>¥3400</td> </tr> </table>
Exemplo 3
Como adicionar cor de fundo a uma linha da tabela (usando CSS):
<table> <tr style="background-color:#FF0000"> <th>Mês</th> <th>A poupança</th> </tr> <tr> <td> Janeiro</td> <td>¥3400</td> </tr> </table>
Exemplo 4
Como alinhar verticalmente: <tr>
do conteúdo (usando CSS):
<table style="height:200px"> <tr style="vertical-align:top"> <th>Mês</th> <th>A poupança</th> </tr> <tr style="vertical-align:bottom"> <td> Janeiro</td> <td>¥3400</td> </tr> </table>
Exemplo 5
Como criar um título para a tabela:
<table> <tr> <th>Nome</th> <th>E-mail</th> <th>Telefone</th> </tr> <tr> <td>Bill Gates</td> <td>bill.gates@example.com</td> <td>138-1234-5678</td> </tr> </table>
Exemplo 6
Como criar uma tabela com cabeçalho:
<table> <caption>ly savings</caption> <tr> <th>Mês</th> <th>A poupança</th> </tr> <tr> <td> Janeiro</td> <td>¥3400</td> </tr> <tr> <td> Fevereiro</td> <td>¥4500</td> </tr> </table>
Exemplo 7
Como definir células de tabela que se estendem por várias linhas ou colunas:
<table> <tr> <th>Nome</th> <th>E-mail</th> <th colspan="2">Telefone</th> </tr> <tr> <td>Bill Gates</td> <td>bill.gates@example.com</td> <td>138-1234-5678</td> <td>186-2345-6789</td> </tr> </table>
Atributos globais
<tr>
A etiqueta também suporta Atributos globais no HTML.
Atributos de evento
<tr>
A etiqueta também suporta Atributos de evento no HTML.
Configurações CSS padrão
A maioria dos navegadores exibirá os seguintes valores padrão <tr>
Elemento:
tr { display: table-row; vertical-align: inherit; border-color: inherit; }
Suporte ao navegador
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Suporte | Suporte | Suporte | Suporte | Suporte |