Sub topic 6
Lists, figures, quotes and addresses
This chapter assumes you know basic HTML syntax (tags, attributes, nesting). It also assumes you can open your browser's developer tools. Earlier chapters covered landmarks, headings and sectioning. This chapter covers the elements that group content inside those regions: lists, figures, quotations and contact details.
Why grouping elements matter
A group of related items is a different thing from several unrelated paragraphs. Grouping elements tell the browser where a group starts, where it ends, and what kind of group it is. A screen reader can then announce "list, 4 items" before reading the first item. The reader can skip the whole list or jump to its end.
The same applies to figures and quotations. Marking them up lets software connect a caption to its image, or a quotation to its source. A visual style that only looks like a caption or a quote does neither.
Lists
HTML has three list types. Choose by what the items mean, not by how the bullets look.
| Element | Meaning | Use when |
|---|---|---|
| `ul` | Unordered list | Item order does not change the meaning |
| `ol` | Ordered list | Order matters: steps, rankings, sequences |
| `dl` | Description list | Items are name and value pairs: terms, metadata, glossaries |
ul and ol
Only li elements may be direct children of ul and ol. Script-supporting elements such as script and template are also allowed. Wrapping li elements in a div is invalid. Text placed directly inside the list is invalid too.
ol has attributes that change the numbering without changing the meaning:
start="5"begins counting at 5.reversedcounts down, which suits "top 10" lists.typeselects numerals, letters or Roman numerals. CSSlist-style-typeis usually the better choice for appearance.valueon anlisets that item's number explicitly.
<h2>Install the tool</h2>
<ol>
<li>Download the archive.</li>
<li>
Unpack it.
<ul>
<li>On Linux, use <code>tar -xf</code>.</li>
<li>On Windows, use the built-in extractor.</li>
</ul>
</li>
<li>Run the installer.</li>
</ol>
<h2>Top three finishers</h2>
<ol reversed>
<li>Dana</li>
<li>Ravi</li>
<li>Mei</li>
</ol>A nested list goes inside the parent li, not beside it. The second example renders as 3, 2, 1, and the markup stays in the order Dana, Ravi, Mei.
Navigation is a list
Navigation links are a set of items, so the standard pattern is a ul inside nav. This is why the page skeleton earlier in this tutorial put li elements around each link. Assistive technology reports how many links the menu contains.
dl, dt and dd
A description list holds groups. Each group has one or more dt (term) elements followed by one or more dd (description) elements. HTML allows a div around each group, which helps with styling.
<dl>
<div>
<dt>Status</dt>
<dd>Published</dd>
</div>
<div>
<dt>Authors</dt>
<dd>Sam Lee</dd>
<dd>Priya Nair</dd>
</div>
</dl>Do not use dl for page layout, or just to indent text. Use it when the content really is a set of names and values. It does not suit dialogue, which the spec previously allowed but now discourages.
figure and figcaption
figure wraps self-contained content that is referenced from the main text but could move elsewhere without breaking the flow. Examples are an image, a diagram, a code listing or a poem. figcaption, if present, must be the first or last child of the figure.
<figure>
<img src="growth.png" alt="Line chart: signups doubled between March and June">
<figcaption>Figure 2. Monthly signups, March to June.</figcaption>
</figure>
<figure>
<pre><code>const total = items.reduce((sum, n) => sum + n, 0);</code></pre>
<figcaption>Listing 1. Summing an array.</figcaption>
</figure>Points that trip people up:
- A
figureis not only for images. Code, tables and quotations can all sit in one. - The caption and the
alttext do different jobs. Thealttext describes the image for someone who cannot see it. The caption is visible to everyone and gives context. Do not repeat the same sentence in both. - An image that is merely decoration does not need a
figure. Usealt=""instead. - The accessible name of a
figurecomes from itsfigcaption, so a screen reader can announce it as a named group. - Do not wrap every image in a
figure. If removing the image would break the surrounding sentence, it is not self-contained.
Quotations
blockquote
blockquote marks a longer quotation taken from another source. The quoted text goes inside, usually in p elements. The cite attribute holds a URL for the source. Browsers do not display it, and many assistive tools ignore it, so visible attribution is still needed.
To attribute a quotation visibly, place the blockquote in a figure and put the attribution in the figcaption. The attribution is not part of the quoted text, so it must stay outside the blockquote.
<figure>
<blockquote cite="https://example.com/essay">
<p>Markup should describe meaning, and CSS should describe appearance.</p>
</blockquote>
<figcaption>
Sam Lee, <cite>On Markup</cite>
</figcaption>
</figure>q
q is the inline version for short quotations inside a sentence. Browsers add language-appropriate quotation marks automatically. Do not type quote characters yourself, or they will appear twice.
<p>The guide says <q cite="https://example.com/guide">use native elements first</q>, and this page follows it.</p>cite
cite marks the title of a work: a book, article, film or song. The current specification does not allow it for a person's name alone. It is not a replacement for cite the attribute, which is a separate feature on blockquote and q. Browsers usually italicize it.
address
address supplies contact information for the nearest article ancestor, or for the whole page if there is none. The usual place is the author line of an article or the page footer.
<footer>
<address>
Questions? Email <a href="mailto:[email protected]">[email protected]</a>
or call <a href="tel:+15550100">555-0100</a>.
</address>
</footer>The common mistake is using address for any postal address. A shop's location listed in the body of an article is just text. Use a p with br or separate lines for that. Also keep other content out of address, such as publication dates. Browsers italicize it by default, but you can change that with CSS.
Choosing among these elements
Checking the result in devtools
Open the Accessibility pane in your browser's developer tools and select a list. You should see a node with the role list and children with the role listitem. Select a figure, and the role is figure with the caption as its name. If your styled list shows up as generic instead, you have hit the Safari behavior above, or you used div elements where li elements belong.
Summary of common errors
- Using
brtags to fake a list of items. Useulorol. - Putting
divor text directly insideulandol. - Using
blockquoteonly to indent text. Use CSS margin. - Putting the attribution inside the
blockquote. - Using
addressfor any address on the page. - Using
citefor a person's name when it is not a work title.
Exercise
A page shows a quotation from a book, with the author's name and the book title under it. Which elements do you use, and where does the attribution go? Also, why should you not wrap the author's name in address?
Show answer
Wrap the quotation in blockquote (with p inside) and put both in a figure. Place the attribution in the figcaption, outside the blockquote. Wrap the book title, but not the author's name, in cite. The address element is only for contact information for the nearest article or the page, not for naming the author of a quoted work.
Exercise
A designer asks you to remove the bullets from your site menu with list-style: none. What do you check afterward, and what do you add if the check fails?
Show answer
Check in a screen reader (VoiceOver in Safari) or the devtools Accessibility pane that the menu is still announced as a list with the right number of items. If Safari no longer exposes the list, add role="list" to the ul.