Balise <tr> HTML
Definition and Usage
<tr>
tags define rows in HTML tables.
<tr>
elements contain one or more <th> or <td> elements.
See also:
HTML Tutorial:Tableau HTML
HTML DOM Reference Manual:TableRow Object
CSS Tutorial:Set table styles
Instance
Example 1
A simple three-row HTML table; one header row and two data rows:
<table> <tr> <th>month</th> <th>savings</th> </tr> <tr> <td>January</td> <td>¥3400</td> </tr> <tr> <td>February</td> <td>¥4500</td> </tr> </table>
Example 2
How to align: <tr>
Content within (using CSS):
<table style="width:100%"> <tr> <th>month</th> <th>savings</th> </tr> <tr style="text-align:right"> <td>January</td> <td>¥3400</td> </tr> </table>
Example 3
How to add a background color to a table row (using CSS):
<table> <tr style="background-color:#FF0000"> <th>month</th> <th>savings</th> </tr> <tr> <td>January</td> <td>¥3400</td> </tr> </table>
Example 4
How to vertically align: <tr>
Content within (using 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>¥3400</td> </tr> </table>
Example 5
How to create a table title:
<table> <tr> <th>name</th> <th>email</th> <th>phone</th> </tr> <tr> <td>Bill Gates</td> <td>bill.gates@example.com</td> <td>138-1234-5678</td> </tr> </table>
Example 6
How to create a table with a title:
<table> <caption>monthly savings</caption> <tr> <th>month</th> <th>savings</th> </tr> <tr> <td>January</td> <td>¥3400</td> </tr> <tr> <td>February</td> <td>¥4500</td> </tr> </table>
Example 7
How to define a table cell spanning multiple rows or columns:
<table> <tr> <th>name</th> <th>email</th> <th colspan="2">Téléphone</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>
Attributs globaux
<tr>
Les balises prennent également en charge Attributs globaux dans HTML.
Attributs d'événement
<tr>
Les balises prennent également en charge Attributs d'événement dans HTML.
Configuration CSS par défaut
La plupart des navigateurs utiliseront les valeurs par défaut suivantes pour afficher <tr>
Élément :
tr { display: table-row; vertical-align: inherit; border-color: inherit; }
Support du navigateur
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |