Sub topic 14
A process for choosing the right element
This chapter assumes you know basic HTML syntax, can open your browser's developer tools, and have met the landmark, heading, text-level, form and interactive elements covered earlier. Here you combine them into a repeatable decision process.
Ask what the content is, not how it looks
Start with the purpose of the content. A bold line, a gray box and a blue rounded rectangle are appearances, and CSS can produce any of them. Ask these questions instead, in order:
- What role does this content play: navigation, a main topic, a quotation, a data set, a control?
- Does the user act on it? If so, does the action go to another place (
a) or do something on this page (button)? - Is it a group of things? Lists, tables,
figureandfieldseteach describe a different kind of group. - Is it a phrase inside text with its own meaning, such as a date, code or an abbreviation?
- Only if none of these fit, use
divorspan.
Quick reference
| Content | Element | Reason |
|---|---|---|
| Link to another page | `a` with `href` | Navigates and can be opened in a new tab |
| Save, open a menu, submit | `button` | Focusable, works with Enter and Space |
| Steps in order | `ol` | Order is part of the meaning |
| Image with a caption | `figure` and `figcaption` | Ties the caption to the image |
| Rows and columns of data | `table` with `th` | Cells are linked to their headers |
| A date | `time` with `datetime` | Machine-readable value |
| Show or hide extra text | `details` and `summary` | Built-in toggle |
Worked example
Suppose a designer hands you a "card" with a title, a posted date, a description and a "Read more" link.
<article>
<h3>Semantic HTML in practice</h3>
<p>Posted <time datetime="2026-11-30">30 November 2026</time></p>
<p>How landmarks and headings help every reader.</p>
<a href="/articles/semantic-html">Read more</a>
</article>Each choice follows the process:
- The card makes sense on its own, so it is an
article. - The title labels the card, so it is a heading. The level comes from where the card sits in the page outline, not from the font size you want.
- The date is a phrase with a machine-readable value, so it is
time. - "Read more" goes to another page, so it is
a, notbutton.
A div would have been right only if the card had no meaning of its own and existed purely for layout.
Test your choice
Before you accept an element, run three checks:
- Remove the CSS. The page should still read in a sensible order, with a clear structure.
- Use only the keyboard. Tab to every control and activate it with Enter or Space.
- Check the accessibility tree. In devtools, confirm the role and name match your intent.
Exercise
A "Delete account" control opens a confirmation dialog on the same page and does not change the URL. Which element should it be, and why not a?
Show answer
Use button type="button". It triggers an action on the current page, and a button is focusable and works with Enter and Space by default. An a is for navigation to a destination, so a screen reader would announce it as a link and promise a page change that never happens.