HTML Tag Reference - HTML tag <tr>








This <tr> element creates a single row inside a <table> element. In turn, the cells in each row are created by the <td> element.

Browser compatibility

<tr> Yes Yes Yes Yes Yes

What's new in HTML5

All the layout attributes are deprecated in HTML5.

Attribute

Attribute Value Description
align right
left
center
justify
char
Not supported in HTML5.
Align the table row content
bgcolor rgb(x,x,x)
#xxxxxx
colorname
Not supported in HTML5.
Set a table row background color
char character Not supported in HTML5.
Align the table row content to a character
charoff number Not supported in HTML5.
Sets the number of characters to align the content from the character in the char attribute
valign top
middle
bottom
baseline
Not supported in HTML5.
Vertical aligns the table row content




Global Attributes

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

Event Attributes

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

Default CSS Settings

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

Example

<html>
<body>
     <table>
          <tr>
               <td>Cell 1</td>
               <td>Cell 2</td>
          </tr>
          <tr>
               <td>Cell 3</td>
               <td>Cell 4</td>
          </tr>
     </table>
</body><!--from   w  ww .  jav a 2  s.com-->
</html>

Click to view the demo





rowspan attribute

The integer value of this attribute determines how many table rows a cell spans.

<html>
<body>
     <table border="1">
          <tr>
               <th rowspan="2">Cell 1</th>
               <th>Cell 2</th>
               <th rowspan="3">Cell 3</th>
               <th>Cell 4</th>
               <th>Cell 5</th>
          </tr>
          <tr>
               <th rowspan="3">Cell 7</th>
               <th rowspan="2">Cell 9</th>
               <th>Cell 10</th>
          </tr>
          <tr>
               <th>Cell 6</th>
               <th>Cell 11</th>
          </tr>
          <tr>
               <th>Cell 12</th>
               <th>Cell 8</th>
               <th>Cell 13</th>
               <th>Cell 14</th>
          </tr>
     </table>
</body><!--from w  w  w  . jav a  2s .  c om-->
</html>

Click to view the demo