Lists and page structure
Lists that announce themselves, and the landmark elements that let a reader — or a screen reader — jump straight to the part they want.
Lists
Three list elements cover almost everything. <ul> is an unordered list: the order does not matter. <ol> is ordered: the order is the meaning, and the browser numbers it for you. <dl> is a description list, for pairs — a term and its definition, a key and its value.
Every item in the first two is an <li>. Because the list is a real element, a screen reader says "list, 5 items" before reading them, and you can jump past it. A paragraph of bullet characters gets none of that, and its items are simply a run-on sentence when read aloud.
A recipe with real lists
Turn the ingredients into an unordered list and the steps into an ordered list, one `<li>` per item.
3 left to do
- The ingredients are an unordered list
- The steps are an ordered list
- There are at least eight list items in total
Wrap the whole group: <ul><li>Flour</li>…</ul>, and <ol> for the steps.
Lists can hold lists
A list item can contain another list, and that nesting is how you show a sub-step without inventing a new element. Put the inner <ul> or <ol> inside the <li> it belongs to, after that item’s own text. A list that sits beside the items instead of inside one is a list the browser has to repair.
A description list is different: <dl> holds <dt> terms and <dd> descriptions, and one term can have several descriptions. It is for pairs — a glossary, a set of details, a menu with prices — not for prose that happens to start with a bold word. A worked example reads as two pairs rather than four lines: <dl><dt>Delivery</dt><dd>Two days</dd><dt>Collection</dt><dd>Free</dd></dl>.
Lists of links
A navigation menu is a list of links, and marking it as one is not a technicality. A screen reader announces "list, 4 items" before reading the links, so a visitor knows how much navigation there is and can skip it in one movement. The same links in a run of paragraphs are four links in a sentence, and there is no boundary to skip. Put the <ul> inside the <nav>, one <li> per link; the list supplies the count and the nav supplies the name.
The landmarks of a page
Most pages have the same few regions: a header, navigation, the main content, maybe a sidebar, a footer. HTML names each of them, and those names are landmarks — the browser and assistive technology can list them so a visitor can jump straight to the main content instead of tabbing through a menu on every page.
The ones you will use constantly
<header>— the top of a page or of an article: a title, a logo, a byline.<nav>— a group of navigation links. Label it when there is more than one.<main>— the content this page exists for. Exactly one per page, and it must not be nested inside another landmark.<article>— something that stands on its own: a post, a card, a comment.<section>— a thematic group, usually with a heading of its own.<aside>— related but secondary: a sidebar, a pull quote, a set of links.<footer>— the bottom: copyright, contact, small print.
Give the page its landmarks
Replace the three plain <div> wrappers with the elements that say what each region is.
3 left to do
- The top region is a header
- The middle region is an article
- The bottom region is a footer
The top one is a <header>, the middle holds the article, and the last is a <footer>.
Landmarks need headings
A <section> is not a generic box with a nicer name. It is a thematic group, and it should have a heading; without one it is a region nobody can name. If you cannot write the heading, the content probably belongs in the surrounding section or in a <div>.
<article> is for something that could be lifted out and still make sense: a post, a card, a comment. <main> is for the one thing the page exists for, and it must not sit inside a header, a nav, an aside, an article or a footer. Those rules are what let a reader jump to the content instead of tabbing through the same menu on every page.
Two ways into the same page
Landmarks and headings are two maps of the same document, and they answer different questions. The landmark list says where a region is — header, navigation, main, footer — so a reader can jump straight to the content. The heading list says what the page covers, level by level, so a reader can jump to the section about delivery. A page with landmarks but no headings can be entered and not navigated; a page with headings but no landmarks makes the reader pass the menu on every visit. Write both, and keep them in the order of the visible page.
Three structural mistakes worth catching early: an <li> outside a list, which may render but cannot be navigated; more than one <main> on a page, which makes jump-to-content ambiguous; and a <section> with no heading, which announces a region with no name. A <div> is honest about having no meaning — use it when that is the truth.
Try these next
- Nest a three-step list inside the second item of an ordered list and check the numbering.
- Write a
<dl>for three terms, and give one term two<dd>descriptions. - Give every
<section>on a page a heading, then remove one and see what the landmark list loses.
A <div> means "a box with no meaning". There is a time for it — a styling hook with nothing to say — but if a region of your page is a header, a nav or an article, say so. The element is already there.
Check what you learned
One question at a time. A wrong answer explains itself — take another go.
Part 1 of 5
When should you reach for <ol> rather than <ul>?
