CKTIS / HTML
table — data table
The `table` element represents related data in rows and columns. Use it for tabular data, not for arranging page elements.
Version: WHATWG HTML Living Standard; index snapshot date recorded separately
Syntax
<table><caption>…</caption><thead><tr><th scope="col">…</th></tr></thead><tbody><tr><td>…</td></tr></tbody></table>table represents multidimensional data in a grid of rows and columns. tr denotes a row, th a header cell, and td a data cell. Both the opening and closing table tags are required.
The element order is an optional caption, colgroup elements, an optional thead, then tbody groups or direct tr rows, and finally an optional tfoot. Do not mix direct tr children with tbody. Script-supporting elements are also allowed.
caption gives the table a title. In simple tables, scope="col" and scope="row" specify header relationships with data. Merely using thead does not turn td cells into headers. Do not use tables for page layout; this makes data harder to interpret, especially for screen-reader users.
Examples
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Stock table</title>
</head>
<body>
<table>
<caption>Stock</caption>
<thead>
<tr><th scope="col">Item</th><th scope="col">Count</th></tr>
</thead>
<tbody>
<tr><th scope="row">Pens</th><td>3</td></tr>
<tr><th scope="row">Books</th><td>2</td></tr>
</tbody>
</table>
</body>
</html>Result
Plain-text schematic (the browser does not display the pipe separators): Stock Item | Count Pens | 3 Books | 2
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.