BEST SITE FOR WEB DEVELOPERS
HTML5. W3Schools in English. The complete tag guide

Ua

HTML <tr> Tag


Example

A simple HTML table with three rows; one header row and two data rows:

<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>
Try it Yourself »

More "Try it Yourself" examples below.


Definition and Usage

The <tr> tag defines a row in an HTML table.

A <tr> element contains one or more <th> or <td> elements.


Browser Support

Element
<tr> Yes Yes Yes Yes Yes

Global Attributes

The <tr> tag also supports the Global Attributes in HTML.


Event Attributes

The <tr> tag also supports the Event Attributes in HTML.


More Examples

Example

How to align content inside <tr> (with 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>
Try it Yourself »

Example

How to add background-color to a table row (with CSS):

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

Example

How to vertically align content inside <tr> (with 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>
Try it Yourself »

Example

How to create table headers:

<table>
  <tr>
    <th>Name</th>
    <th>Email</th>
    <th>Phone</th>
  </tr>
  <tr>
    <td>John Doe</td>
    <td>john.doe@example.com</td>
    <td>123-45-678</td>
  </tr>
</table>
Try it Yourself »

Example

How to create a table with a caption:

<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>
Try it Yourself »

Example

How to define table cells that span more than one row or one column:

<table>
  <tr>
    <th>Name</th>
    <th>Email</th>
    <th colspan="2">Phone</th>
  </tr>
  <tr>
    <td>John Doe</td>
    <td>john.doe@example.com</td>
    <td>123-45-678</td>
    <td>212-00-546</td>
  </tr>
</table>
Try it Yourself »

Related Pages

HTML tutorial: HTML Tables

HTML DOM reference: TableRow object

CSS Tutorial: Styling Tables


Default CSS Settings

Most browsers will display the <tr> element with the following default values:

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