**`<tr>`** ("table row") is a horizontal row within a table, and its direct children must be `<th>` or `<td>` cells (or, in obscure cases, nothing else). Rows are typically grouped inside `<thead>`, `<tbody>`, or `<tfoot>` sections for clearer structure, though a `<table>` can also contain `<tr>` rows directly without those grouping elements for simple tables.
1Understanding <tr>
`<tr>` ("table row") is a horizontal row within a table, and its direct children must be <th> or <td> cells (or, in obscure cases, nothing else). Rows are typically grouped inside <thead>, <tbody>, or <tfoot> sections for clearer structure, though a <table> can also contain <tr> rows directly without those grouping elements for simple tables.
Every <tr> in a table should ideally have the same number of cells (accounting for colspan/rowspan) — mismatched cell counts across rows can make a table's structure ambiguous to both browsers and screen readers.
<table>
<tr>
<th>Product</th>
<th>Price</th>
</tr>
<tr>
<td>Widget</td>
<td>$9.99</td>
</tr>
</table>2Practical Example
Here is a real-world application of <tr> showing how it is used in production HTML.
<!-- A row using colspan to merge cells -->
<tr>
<td colspan="2">Spans two columns</td>
</tr>3Best Practices
Follow these guidelines when working with <tr>:
1. Keep the number of cells consistent across rows in the same table (accounting for colspan/rowspan)
2. Group rows into <thead>/<tbody>/<tfoot> for larger, clearer tables
3. Use <th> for the row's header cell when a row itself acts as a label (e.g. a row header)
Tip: Every <tr> in a table should ideally have the same number of cells (accounting for colspan/rowspan) — mismatched cell counts across rows can make a table's structure ambiguous to both browsers and screen readers.
<table>
<tr>
<th>Product</th>
<th>Price</th>
</tr>
<tr>
<td>Widget</td>
<td>$9.99</td>
</tr>
</table>