03 / 07
Semantic elements and page structure.
HTML is the markup language that tells the browser what a page contains and how it is structured. Every piece of it, a heading, a paragraph, a link, an image, a form, is written as an element. An element is made of an opening tag, its content and a closing tag; settings are added to the opening tag as attributes.1
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Page title</title>
</head>
<body>
<p>Hello <strong>world</strong>.</p>
<img src="cat.jpg" alt="A grey cat asleep on a windowsill" />
</body>
</html><head> carries information the user does not see (the title, the character set), and <body> holds everything that appears on screen. Void elements such as <img> and <br> have no content and no closing tag. Elements have to nest properly: <p><strong>…</strong></p> is right, <p><strong>…</p></strong> is wrong.1
Semantic HTML means choosing an element for what it means, not for how it looks.2 <div> and <span> tell the browser and assistive tools nothing about the content. <nav>, <button> and <h2> say what they are.
This matters because the browser builds an accessibility tree from your HTML, and that is what screen readers read the page from. Meaningful elements also give the page sections that can be navigated to: landmarks.2 Appearance is the job of CSS, not HTML; do not pick an element because you like its default styling.2
The scale of this is large: in 2026, 53.1% of a million home pages were missing alternative text on images and 51% were missing labels on form fields.3 Most of those are errors the right element would have prevented.
These are the main elements for dividing up a page:4
| Tag | What it's for |
|---|---|
<header> | The top of the page or of a section (logo, title) |
<nav> | The main navigation links |
<main> | The page's own main content; used once per page |
<article> | Self-contained content that stands on its own (a blog post, a product card) |
<section> | A thematic group; it should start with a heading |
<aside> | Information indirectly related to the main content |
<footer> | The bottom of the page or of a section |
<body>
<header>
<nav>…</nav>
</header>
<main>
<article>
<h1>Post title</h1>
<p>…</p>
</article>
<aside>Related posts</aside>
</main>
<footer>…</footer>
</body>The HTML Standard is clear that <section> is not a general-purpose box; when all you need is a container to style, use a <div>.5 The <header> and <footer> above become page-level landmarks, while ones inside an <article> or a <section> do not.6
Tip
There is nothing wrong with a <div> when no meaningful element fits. The problem is writing <div> when one does.4
There are six heading levels, <h1> through <h6>. Headings work like the page's table of contents, and screen reader users navigate by jumping between them.7
Do
Use a single <h1> on a page, as a rule.
Go down the levels in order: <h1>, <h2>, <h3>.
Don't
Do not jump from <h2> to <h4>.
Do not use a heading to make text bigger; CSS font-size is there for that.8
A link takes you somewhere else; a button does something on the page you are on, such as opening a menu or submitting a form.9
<a href="/prices">See the prices</a>
<button type="button">Open the menu</button>Building a button out of <div onclick="…"> looks easy, but it throws away everything the browser gives you for free, keyboard focus and working with Enter and Space among it; you then have to write all of it yourself.710
Warning
A <div> does not behave like a button. Reach for <button> first.
Every form field needs a <label>. The label tells a screen reader what the field is for, and clicking it focuses the field.11
<label for="email">Email</label>
<input id="email" type="email" name="email" />alt describes, briefly, the information the image carries. If the image is decorative, leave alt="" and the screen reader skips it. For an image inside a link or a button, the alt text describes where it goes or what it does.12
Instead of "click here", write text that means something read on its own: "more information about whales".7
ARIA is a set of attributes that add a role and a state to an element where HTML falls short (role, aria-label). The W3C's first rule is this: if a native HTML element gives you the meaning and the behaviour you need, use it instead of adding ARIA.13 role="button" adds the meaning only, not the keyboard behaviour.2 The data also shows a higher average error count on pages that use ARIA (59.1 against 42), though some of that is explained by more complex pages using more of it.3
Full course: web.dev's free Learn HTML course.14
Every element defined: MDN's element list, grouped by what each one does.15
Check your own page: the W3C's Nu Html Checker.16
Talk: Jen Luker on button and div (12 min).10
Talk: Marcy Sutton on links and buttons.17
Sources
Element structure, attributes, void elements, nesting, the doctype and `html/head/body`.
Choosing an element by meaning, the accessibility tree, and the behaviour `role` does not bring with it.
The most common accessibility errors on home pages, and error counts against ARIA use.
What `header`, `nav`, `main`, `article`, `section`, `aside` and `footer` mean, with the warning about `div`.
The definitions of `article` and `section`; `section` not being a generic container.
Landmark roles and which `header`/`footer` becomes one.
`button` against `div`, headings, `label`, `alt` and link text.
Not skipping levels, one `h1`, and not using a heading for size.
A link goes to another resource, a button acts on the page you are on.
12 minutes. The roles, tabindex and event handlers it takes to turn a `div` into an accessible button.
Every form control needs a `label`.
When alt text is empty, descriptive or functional.
ARIA's first rule: the native HTML element first.
A free HTML course from start to finish.
Every element, grouped by what it does.
The W3C's HTML validator.
Choosing between a link and a button, form features and ARIA.
Check the lesson's main ideas with three questions.
Your progress is stored only in this browser.
Last updated: November 3, 2026