Skip to main content

The <tr> Element

As defined in the HTML Living Standard, the <tr> element represents a row of cells in a table. It acts as the container for either header cells (<th>) or data cells (<td>).

Visual Example:

Element Role
<tr> Row Container
<td> Data Cell

(The highlighted region above is a single <tr>.)

<table> <tr> <th>Header 1</th> <th>Header 2</th> </tr> <tr> <td>Value 1</td> <td>Value 2</td> </tr> </table> View HTML Living Standard: The tr element

Structural Requirements

WCAG Requirement: Info and Relationships

Success Criterion 1.3.1 (Level A): Information, structure, and relationships conveyed through presentation can be programmatically determined.

The <tr> element is the programmatic anchor for horizontal relationships in a table. Assistive technologies use the row structure to calculate the table's dimensions. For a screen reader user, the browser announces the row count (e.g., "Row 2 of 5") as they navigate. This allows users to maintain their orientation within a dataset—a critical relationship that is conveyed to sighted users via visual alignment.

Understand SC 1.3.1: Info and Relationships

Styling for Scannability

Following SMACSS Module Rules, table rows are often styled to improve data scannability for all users.

/* Zebra Striping Example */ tr:nth-child(even) { background-color: #f9f9f9; } /* Hover Highlight Example */ tr:hover { background-color: #e2e8f0; }

A11y Tip: Logical Reading Order

Never use <tr> elements to create a layout that differs from the logical reading order. Screen readers follow the DOM order of the rows; if the visual layout suggests a different sequence, the Info and Relationship requirement is failed.