<tr>
The HTML <tr> element represents a row in a table, consisting of one or more table cells (<td> or <th>), used to structure and present data in a tabular format.
tr tag
The <tr>
element in HTML is used to create a row inside a table. It is placed within the <table>
element and typically includes <td>
(for standard cells) or <th>
(for header cells).
Syntax
index.html
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
</tr>
<tr>
represents a table row.tr Demo
Emil | Tobias | Linus |
16 | 14 | 10 |
index.html
<table>
<tr>
<td>Emil</td>
<td>Tobias</td>
<td>Linus</td>
</tr>
<tr>
<td>16</td>
<td>14</td>
<td>10</td>
</tr>
</table>
- Tables can have multiple rows, and keeping the number of cells consistent across rows helps maintain structure.
If needed, cells within a row can span multiple columns or rows using the
colspan
or rowspan
attributes.Attributes
align
(Deprecated in HTML4.01, Obsolete in HTML5): Determines how content inside the row is aligned. Options include:left
: Aligns content to the left.center
: Centers content.right
: Aligns content to the right.justify
: Justifies text.char
: Aligns based on a specific character, with offsets set bychar
andcharoff
.
See also
- Other table-related HTML elements:
<caption>
<col>
<colgroup>
<table>
<tbody>
<td>
<tfoot>
<th>
<thead>
- CSS styling for
<tr>
, including: Using the:nth-child
pseudo-class to style specific rows or columns within a table.
Conclusion
The <tr>
element in HTML defines a row within a table. It contains either <td>
(data cells) or <th>
(header cells). Rows are grouped inside the <table>
element, and each row is typically composed of multiple cells.