| Depr. | Empty | Version |
|---|---|---|
| No | No | HTML 2 |
| IE5.5+ | FF1+ | SA1.3+ | OP9.2+ | CH2+ |
|---|---|---|---|---|
| Full | Full | Full | Full | Full |
Syntax
Description
The
tr element is used to create a new row of data in a
table. This element may appear as a
child element of the table element or, if it has been
defined, as a child of a thead, tfoot, or tbody elements.
The table row contains one or more th or td elements, but each
row should contain the same number of cells (regardless of whether they’re
th or td elements), unless cells are
set to span multiple columns using the colspan
attribute (see the section about
colspan in the th
reference for more information). If one row has more table cells
inside it than do the others (for example, if you accidentally create a
header area with 11 th elements, but subsequent rows
have only ten td elements), the web browser will have
to fill in the gaps with empty cells. This can have a disastrous effect on
the data, so be sure to keep count of your cells!
It’s
possible to omit the closing </tr> tag in HTML 4.01, but I’d
advise you to include it, firstly to ensure XHTML compatibility (XHTML
requires the closing tag), but also because it can make reading and thus
maintaining the markup easier when you revisit it at a later
date.
Example
The three rows in this
simple table are created with the opening and closing
tr tags:
<table summary="Interest Rates">
<caption>Interest Rates</caption>
<thead>
<tr>
<th>Account Type</th>
<th>Interest Rate</th>
</tr>
</thead>
<tbody>
<tr>
<td>Smart</td>
<td>From 2%</td>
</tr>
<tr>
<td>Young Saver</td>
<td>From 1.6%</td>
</tr>
</tbody>
</table>
Use This For …
This element is used to start a new row of data.
Compatibility
| Internet Explorer | Firefox | Safari | Opera | Chrome | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 5.5 | 6.0 | 7.0 | 8.0 | 1.0 | 1.5 | 2.0 | 3.0 | 3.5 | 1.3 | 2.0 | 3.1 | 4.0 | 9.2 | 9.5 | 10.0 | 2.0 |
| Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full |
It causes no compatibility issues, and has excellent support across all tested browsers.
In this Section
- align
aligns text in table cells contained inside tr element - bgcolor
defines the background color of the tr - char
sets the character to which cell contents inside the table row should align - charoff
defines the number of characters by which cell contents will be offset from the char - valign
aligns text vertically in table cells contained inside a tr element