tr which stands for Table Row is an HTML element tag and is used to define a row of cells in a table.

You use tr whenever you want to create a table on an HTML page. The column cells can be created by using th (header cell) and td (data cell) element tags.

Example code

Here’s an example of how the tr tag is used to make a table in HTML. This simple table contains three rows and two head columns and six normal columns displaying a name and age of a person:

    <td>John Wick</td>
    <td>Tony Stark</td>
    <td>Jack Sparrow</td>

Let’s take a quick breakdown of what happening in this code:

  1. You begin by adding a table tag. These tags are mandatory to create a table.
  2. Inside the table tag, this is where you will use the tr tag to make a row of cells. You can add one or more rows to each table. Row cells go from up to down.
  3. Inside the tr tags, you add the columns by either using td or th tags. The th tag is used to make the header cell while the td tag is used to make a data cell. Column cells go from left to right.

In short, tr is what makes it possible to make a row of cells and it’s a necessary element to create a table in HTML.

This is how it will turn out on the browser:

what is tr in html image

Some notices about the tr tag

  • The tr tag will usually contain one or more column element tags like th and td
  • The tr comes with the rowspan attribute, giving you the additional option of how many the rows should be span in the table cell.
  • By default, the tr tag does not come with borderlines. You will have to style it by yourself using CSS.