What is the <tr> element in HTML?

The <tr> tag stands for table row. It is used to create a row in a table in HTML.

The table is created by the <table> tag. The header, body, and footer of the table are defined by the <thead>, <tbody> and <tfoot> tags, respectively.

The <tr> tag can be used inside the header, body, or the footer of the table to create a row. Inside a <tr> tag, the <td> or <th> tags are used to create cells to represent data. The row defined by the <tr> tag is divided into cells according to the number of <td> or <th> tags used.

The <td> tag creates a standard data cell, and the <th> tag creates a heading cell.

Syntax

<table>
  <tbody>
    <tr/>
    <tr/>
  </tbody>
<table>

In the above snippet of code, two rows are being created inside the body of the table.

The <table> tag creates the table. The <tbody> tag must always be the child of the <table> tag, as shown. The body of the table can have multiple rows. Each row is defined by the <tr> tag and can have multiple children tags, like <td> or <th>.

Example

  • HTML

A table is created in the above snippet of code that shows the item’s name, quantity, and total price.

We created a table using the <table> tag. The <thead> tag defines the header of the entire table, and the <tbody> tag creates the body.

In the header and the body of the table, <tr> tags are used to create rows.

A single row is created in the header of the table. Three <th> tags divide the row into three heading cells.

Two rows are created inside the body of the table using two <tr> tags, and each row is divided into three standard data cells created by the <td> tag.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved