Web development

Give a page a semantic HTML structure

Use semantic elements to identify the main content, navigation, and surrounding page structure. These elements provide meaning independently of the visual layout chosen in CSS.

Worked example

HTML example · save as example.html and open in a browser

<!doctype html><html lang="en"><title>Reading room</title>
<header><a href="/">Reading room</a></header>
<nav aria-label="Main"><a href="/articles/">Articles</a></nav>
<main><h1>Practical guides</h1><p>Choose a topic to begin.</p></main>
<footer><p>Reference notes and examples.</p></footer></html>

How it works

Main identifies the page’s dominant content, while nav groups navigation links. Header and footer describe their surrounding context. The structure remains understandable with styles disabled and gives assistive technology meaningful regions to navigate.

Limits and mistakes

Semantic elements do not automatically make every interaction accessible. Use one visible primary main region and label multiple navigation regions distinctly. Do not choose an element solely because its default appearance resembles the design.

Check the result

Open the page and inspect its accessibility tree. Confirm the main landmark contains the actual content and that keyboard users can reach every link in a sensible order.

Sources

Reference documentation for the behavior used in this guide: