HTML <tr> Tag

Beginner
7 min read
Updated: Nov 2026
4 examples
Live preview

Definition and Usage

The <tr> element defines a row of cells in a <table>. Fill each row with <td> data cells and/or <th> header cells.

Place rows inside <thead>, <tbody>, or <tfoot> when you can. A <tr> put directly under <table> still works — the browser implies a <tbody>.

Baseline · Widely available.

The element itself is not deprecated. Stable across browsers since about July 2015 (and much earlier in practice).

Deprecated attributes.

Do not use align, bgcolor, char, charoff, or valign on <tr>. Prefer CSS text-align, background-color, and vertical-align.

HTML Syntax

syntax.html
<tr> <th>/<td>…</tr>

The start tag is required. The end tag may be omitted if the next sibling is another <tr>, or if the row is the last child of its thead / tbody / tfoot. Beginners should write both tags.

Attributes

Modern <tr> has no useful element-specific attributes — only globals. These legacy attributes remain for reference:

AttributeDescriptionTry it
alignDeprecated — use CSS text-align insteadTry it
bgcolorDeprecated — use CSS background-color insteadTry it
valignDeprecated — use CSS vertical-align insteadTry it
char / charoffDeprecated — use CSS text-align (and tabular numerals) insteadTry it

Global Attributes

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

Live Preview

Switch presets to see real <tr> rows with header and data cells.

Each <tr> is one horizontal row of th / td cells.

Table
AlfaAL fah
BravoBRAH voh

<tr><td>…</td></tr>

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Basic Data Rows

Each <tr> holds one horizontal set of <td> cells.

HTML
<table>
  <tr>
    <td>Alfa</td>
    <td>AL fah</td>
  </tr>
  <tr>
    <td>Bravo</td>
    <td>BRAH voh</td>
  </tr>
</table>
Try It Yourself

How It Works

  1. Open <table>.
  2. Add a <tr> for the first row.
  3. Put cells in that row with <td>.
  4. Repeat <tr> for each additional row.

Example 2 — Header Row with th

Use <th scope="col"> in the first row to label each column.

HTML
<table>
  <tr>
    <th scope="col">Symbol</th>
    <th scope="col">Code word</th>
  </tr>
  <tr>
    <td>A</td>
    <td>Alfa</td>
  </tr>
</table>
Try It Yourself

How It Works

  1. First <tr> holds column labels.
  2. Use <th scope="col"> so assistive tech knows they head columns.
  3. Next rows use <td> for the data.
  4. Prefer wrapping the header row in <thead> in fuller tables (see example 4).

Example 3 — Row Header Cells

Start a data row with <th scope="row"> when the first cell labels that row.

HTML
<table>
  <tr>
    <th scope="row">A</th>
    <td>Alfa</td>
    <td>AL fah</td>
  </tr>
  <tr>
    <th scope="row">B</th>
    <td>Bravo</td>
    <td>BRAH voh</td>
  </tr>
</table>
Try It Yourself

How It Works

  1. Open each data <tr>.
  2. Put <th scope="row"> first for the row label.
  3. Follow with <td> for the related values.
  4. scope="row" ties that header to cells in the same row.

Example 4 — thead and tbody Rows

Group the header row and body rows for clearer structure.

HTML
<table>
  <thead>
    <tr>
      <th scope="col">Symbol</th>
      <th scope="col">Code word</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th scope="row">A</th>
      <td>Alfa</td>
    </tr>
    <tr>
      <th scope="row">B</th>
      <td>Bravo</td>
    </tr>
  </tbody>
</table>
Try It Yourself

How It Works

  1. Put the label row in <thead>.
  2. Put data rows in <tbody>.
  3. Each section still uses <tr> the same way.
  4. CSS like tr:nth-of-type can stripe body rows more reliably when groups are explicit.

Edge Cases & Pitfalls

Most tr bugs are wrong parents, missing cells, or styling with deprecated attributes.

parent

Only under table groups

Valid parents are thead, tbody, tfoot, or table (which implies tbody). Do not put tr in a div.

selectors

table > tr may fail

When the browser inserts an implied tbody, rows are no longer direct children of table. Prefer tbody tr or explicit groups.

a11y

Label columns and rows

Use <th> with scope so screen readers can announce headers for each cell.

style

Style with CSS, not presentational attributes

Skip deprecated align / bgcolor / valign. Stripe rows with :nth-of-type when helpful.

Browser Support

The <tr> element is core HTML for tables in every browser. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

<tr>

Widely available since about July 2015 (and long before). All major browsers support table rows; deprecated presentational attributes should be avoided.

99% Global support (approx.)
Google Chrome All
Full support
Mozilla Firefox All
Full support
Apple Safari All
Full support
Microsoft Edge All
Full support
Opera All
Full support
Samsung Internet All
Full support
Internet Explorer All
Supported
<tr> Universally supported

Bottom line: Safe everywhere for table rows. Prefer thead/tbody structure, th with scope, and CSS instead of deprecated row attributes.

Key Takeaways

  • Role: <tr> is one horizontal row of table cells.
  • Cells: fill rows with th and/or td.
  • Structure: prefer thead / tbody / tfoot groups.
  • Style: skip deprecated align / bgcolor — use CSS.

One line: wrap each table row in <tr> and fill it with th/td cells.

Default CSS Settings

Typical user-agent styling for tr:

default.css
tr {
  display: table-row;
  vertical-align: inherit;
}

Borders and zebra stripes come from your CSS on table, th, td, or tr:nth-of-type — not from special defaults on tr alone.

Frequently Asked Questions

The tr element defines one row in a table. Fill it with th header cells and/or td data cells.
As a child of thead, tbody, or tfoot. You may also put tr directly under table; the browser then implies a tbody.
Zero or more th and/or td cells (plus optional script-supporting elements). Do not nest another table row inside a cell without a nested table.
No for new work. Those attributes are deprecated. Use CSS text-align, vertical-align, and background-color instead.
Not required, but recommended. A header row of th cells inside thead makes the table structure clearer for people and assistive tech.
No. The element itself is Baseline. Only some presentational attributes on it are deprecated.

Next: track

Add timed text tracks for media with the HTML track element.

track tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

12 people found this page helpful