Learn HTML – Part 32 – tr Tag – Table Rows
The HTML tr tag is used to define a row inside an HTML table.
Each row contains one or more table cells, which can be header cells (th) or data cells (td).
What is the tr Tag?
The tr tag stands for Table Row.
It is used inside the table element to organize data into horizontal rows.
Basic Syntax
<table>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
</tr>
</table>
Example – Table Row with Data Cells
<table border="1">
<tr>
<td>John</td>
<td>25</td>
</tr>
</table>
Output:
| John | 25 |
Example – Multiple Table Rows
<table border="1">
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>Alice</td>
<td>23</td>
</tr>
<tr>
<td>Bob</td>
<td>28</td>
</tr>
</table>
Output:
| Name | Age |
|---|---|
| Alice | 23 |
| Bob | 28 |
Table Structure Overview
A typical HTML table structure looks like this:
table
├── tr (table row)
│ ├── th (header cell)
│ └── td (data cell)
Why Use the tr Tag?
- Organizes data into rows
- Helps structure tables clearly
- Works with
thandtdelements - Improves readability of tabular data
Each
trelement represents one horizontal row in a table.
Common Mistakes Beginners Make
- Placing
tdorthdirectly insidetablewithouttr - Creating inconsistent numbers of cells in rows
- Using rows incorrectly for layout instead of data
Conclusion
The HTML tr tag is used to create rows inside an HTML table.
It works together with th and td elements to organize data in a structured format.
What’s Next?
Now that you understand the tr tag, the next step is learning about the td tag, which is used to define data cells inside table rows.
Next: Learn HTML – Part 33 – td Tag – Table Data Cells →
Series: Learn HTML Series
