Lists and tables
Three kinds of lists, and building data tables that are semantically correct instead of layout hacks.
The three list types
<ul>
<li>Unordered: order does not matter</li>
</ul>
<ol>
<li>Ordered: sequence matters</li>
<li>Second step</li>
</ol>
<dl>
<dt>HTML</dt><dd>Structure of a web page</dd>
<dt>CSS</dt><dd>Appearance of a web page</dd>
</dl>ulβ bullet list; the only legal children areli.olβ numbered; control numbering with CSS, orstart/reversedattributes.dlβ description list of term/definition pairs; ideal for glossaries and metadata.
Lists may nest: put the child ul inside the li it belongs to, not beside it.
Tables are for data only
Use a table when you genuinely have rows and columns of data. Never use one for page layout β it breaks flexibility, accessibility, and mobile rendering.
<table>
<caption>Monthly active users</caption>
<thead>
<tr><th scope="col">Month</th><th scope="col">Users</th></tr>
</thead>
<tbody>
<tr><th scope="row">July</th><td>1,204</td></tr>
<tr><th scope="row">August</th><td>1,471</td></tr>
</tbody>
<tfoot>
<tr><th scope="row">Total</th><td>2,675</td></tr>
</tfoot>
</table>thead/tbody/tfootgroup rows semantically (and let you style them separately).thwithscopetells assistive tech whether the header applies to its column or row.captionis the table's accessible title β better than a nearby heading.colspan/rowspanmerge cells; use sparingly, they complicate navigation.
FAQ
How do I make a table scroll on mobile?
Wrap it in a container with
overflow-x:auto. Do not let it overflow the viewport and force the whole page sideways.Can I strip all borders?
Yes, with CSS. Borders are presentational β the
border attribute on table is obsolete.Related
Forms and inputs Semantic layout
Last refreshed 2026-09-17.