Skip to: content, navigation

by Ian Lloyd

tr (HTML element)

Spec
Depr. Empty Version
No No HTML 2
Browser support full matrix
IE5.5+ FF1+ Saf1.3+ Op9.2+
Full Full Full Full

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>
Type
table element
Contains
th, td
Contained by
table, thead, tbody, tfoot

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.

Use This For …

This element is used to start a new row of data.

Compatibility

IE5.5Full
6.0Full
7.0Full
Firefox1.0Full
1.5Full
2.0Full
Safari1.3Full
2.0Full
3.0Full
Opera9.2Full
9.5Full

It causes no compatibility issues, and has excellent support across all tested browsers.

In this Section

User-contributed notes

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters