Definition
The <tr>
HTML element is used to define a table row within an HTML table. It represents a single row of data or content within the table structure.
Here’s an example of how to use the <tr>
element:
<table>
<tr>
<td>John Doe</td>
<td>30</td>
<td>New York</td>
</tr>
</table>
In this example, the <tr>
element is used to define a table row. Within the row, three <td>
elements are used to define the table cells or data cells. Each <td>
element represents a piece of data within the row, such as a person’s name, age, and city.
You can add multiple <tr>
elements within a <table>
element to define additional rows of data. Each <tr>
element should have the same number of table cells or <td>
elements to maintain the table structure.
The <tr>
element can also be used in combination with other table-related elements, such as <thead>
, <tbody>
, and <tfoot>
, to further organize and structure the table content.
It’s important to note that the <tr>
element must always be placed within a <table>
element to maintain proper table structure.