CKTIS / HTML
tr — table row
The `tr` element represents a row of cells in an HTML table. It groups `td` data cells and `th` header cells; it is neither a cell itself nor a row group.
Version: WHATWG HTML Living Standard; index snapshot date recorded separately
Syntax
<tr><th scope="row">Label</th><td>Value</td></tr>The tr element represents one table row. Its content is zero or more td, th, and script-supporting elements. Put text and ordinary content elements inside cells, not directly inside tr.
Normally place tr inside thead, tbody, or tfoot. The content model also permits a direct child of table when that table has no tbody children, after any caption, colgroup, and thead. However, when parsing text/html, writing a row directly inside a table implies a tbody start tag; explicit groups make the DOM structure easier to predict.
th denotes a header cell, while td denotes a data cell. Placing a row in thead does not turn its td cells into headers. In the example, scope="col" identifies column headers and scope="row" identifies row headers.
tr supports global attributes. In text/html, its end tag may be omitted before another tr or when there is no more content in its parent. Explicit end tags, as used in the example, improve readability.
Examples
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Table rows</title>
</head>
<body>
<table>
<caption>Scores</caption>
<thead>
<tr><th scope="col">Name</th><th scope="col">Score</th></tr>
</thead>
<tbody>
<tr><th scope="row">Ada</th><td>8</td></tr>
<tr><th scope="row">Lin</th><td>6</td></tr>
</tbody>
</table>
</body>
</html>Result
Scores Name | Score Ada | 8 Lin | 6
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.