<tr> Table Row (X)HTML Element Reference - (X)HTML webDev

<tr>

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. 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.

The <tr> element is used to start a new row of data.

HTML Tag: <tr>

  • Optional <tr> Attributes
  • align can be used to horizontally align the content of the cell. The value can be left, center, right, justify or char.
  • valign can be used to vertically align the content of the cell. The value can be top, middle, bottom or baseline.
  • char can be used to specify a character with which cells will align, such as a decimal point. It is not supported by any major browser.
  • charoff can be used to specify the number of pixels the alignment should be offset from the char character. It is not supported by any major browser.

HTML <tr> Tag

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

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

<tr> Table Row (X)HTML Element Reference - (X)HTML webDev