English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML reference manual

HTML tag大全

HTML: <tr> tag

HTML <tr> tag defines a row in an HTML table. Each <tr> tag can contain one or more <th> tags, which define the title cells in the table, or one or more <td> tags, which define the standard cells in the table. This tag is also commonly known as the <tr> element.

Online examples

HTML tables, simple tables with tr:

!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>HTML tr tag usage (Basic Tutorial Website oldtoolbag.com)</title>
</head>
<body>
<table border="1">
  <tr>
    <th>Column 1 Heading</th>
    <th>Column 2 Heading</th>
  </tr>
  <tr>
    <td>Data in Column 1, Row 2</td>
    <td>Data in Column 2, Row 2</td>
  </tr>
  <tr>
    <td>Data in Column 1, Row 3</td>
    <td>Data in Column 2, Row 3</td>
  </tr>
</table>
</body>
</html>
Test to see ‹/›

In this HTML5In the document example, we used the <table> tag to create a table that has2columns and3rows. The1row is defined by the first <tr> tag. It has2title cells are defined by the <th> tag. The row number of this table is2Rows and the3Rows are defined by the <td> tag to define standard table cells.

Browser compatibility

IEFirefoxOperaChromeSafari

All mainstream browsers support the <tr> tag.

Definition and usage instructions of the tag

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

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

HTML 4.01 With HTML5Differences between

In HTML 5 Does not support the <tr> tag in HTML 4.01 Any attribute in the middle.

Attribute

AttributeValueDescription
alignright
 left
 center
 justify
 char
HTML5 Not Supported. Defines the alignment of the content within the table row.
bgcolorrgb(x,x,x)
#xxxxxx
colorname
HTML5 Not Supported. HTML 4.01 Deprecated. Specifies the background color of the table row.
charcharacterHTML5 Not Supported. Specifies which character to use for text alignment.
charoffnumberHTML5 Not Supported. Specifies the offset of the first alignment character.
valigntop
 middle
 bottom
 baseline
HTML5 Not Supported. Specifies the vertical alignment of the content within the table row.

Global Attributes

Support of <tr> tag Global Attributes of HTML.

Event Attributes

Support of <tr> tag HTML Event Attributes.

Try It - Example

Table Title in the Table
This example demonstrates how to display table titles.

Empty Cell
This example demonstrates how to handle empty cells with " ".

Related Articles

HTML Tutorial:HTML Tables

HTML DOM Reference Manual: Tr Object