Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

html

What is the <tr> element in HTML?

Amaaz Ahmad

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

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.

RELATED TAGS

html

CONTRIBUTOR

Amaaz Ahmad
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring