HTML <tr> Tag

The <tr> tag defines a row in an HTML table. The cells inside it are defined using the <th> (a header cell) or the <td> (a standard cell).

The <tr> element is declared inside the <table> tag.

All the rows in the table contain equal number of cells, which is equivalent to the number of cells in the longest row. If there are less cells in a row, then the browser will automatically fill the row, placing empty cells at the end of it.

If you need to emphasize that there is no data in other cells, then create cell without content where necessary.

The cells added by browser have no borders, and if they go after each other, they will be shown as one integrated cell.

To customize the look of the table use CSS properties.

Syntax

<table> 
  <tr> 
    <td>...</td> 
  </tr> 
</table>

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      th, td {
        padding: 10px;
        border: 1px solid #666;
      }
    </style>
  </head>
   <body>
    <table style="width:80%; margin:30px auto; border-collapse:collapse;">
      <tr>
        <th>Month</th>
        <th>Date</th>
      </tr>
      <tr>
        <td>March</td>
        <td>10.09.2018</td>
      </tr>
      <tr>
        <td>June</td>
        <td>18.07.2018</td>
      </tr>
    </table>
  </body>
</html>

Result

Attributes

Attribute Value Description
align right
left
center
justify
char
Aligns the content in a table row.
Not supported in HTML 5.
bgcolor bgcolor Specifies a background color for a table row.
Not supported in HTML 5.
bordercolor bordercolor Sets the color of the border.
Not supported in HTML 5.
char character Aligns the content in a table row to a character. Is used only if attribute align = "char".
Not supported in HTML 5.
charoff number Sets the number of characters the content will be aligned from the character specified by the char attribute. Is used only if attribute align = "char".
Not supported in HTML 5.
valign top
middle
bottom
baseline
Specifies vertical alignment of the content inside a table row.
Not supported in HTML 5.

The <tr> tag supports the Global Attributes and the Event Attributes.

Browser support