Semantic landmarks and sectioning content
Build semantic, accessible and responsive interfaces from a blank page, and explain why each layout and styling decision works.
What you will be able to do
#- Choose between header, nav, main, section, article and aside based on meaning.
- Explain how landmarks let screen reader users jump around a page.
Overview
#Semantic elements describe the role of a region, not its appearance. A div with a class of header is a generic container; a <header> is a banner landmark that assistive technology can navigate to directly. Screen reader users often move by landmark rather than reading top to bottom, so landmarks are navigation shortcuts.
The rules are about ownership. <header> and <footer> are banner and contentinfo landmarks only when they are not nested inside section, article, aside, nav or main. <main> should appear once per page and holds the primary content. <nav> marks a major navigation block. <section> groups a themed region and normally needs an accessible name. <article> is content that would make sense on its own, such as a post or a card.
<body>
<header>
<a href="/">Acme</a>
<nav aria-label="Primary">
<ul>
<li><a href="/invoices">Invoices</a></li>
<li><a href="/clients">Clients</a></li>
</ul>
</nav>
</header>
<main>
<h1>Invoices</h1>
<section aria-labelledby="open-heading">
<h2 id="open-heading">Open</h2>
<article>Invoice 1042</article>
</section>
</main>
</body>
Nesting matters. A <header> inside an <article> is that article's header, not a page banner. A <section> without a heading or accessible name is often indistinguishable from a div and adds noise. Use the element that matches the meaning you want exposed, and fall back to div when the grouping is purely visual.
Exercises
#Reference answers and expected output are authored, not executed in this browser. Nothing you type is run, and there is no Run or Pass control on this page.
Exercise 1Implement
Mark up a page with a site header containing a primary navigation list, a main region with an h1 and one article, and a footer. Give the navigation an accessible name.
starter.html<body> <!-- build the landmarks --> </body>Reveal the reference answer
reference.html<body> <header> <a href="/">Acme</a> <nav aria-label="Primary"> <ul> <li><a href="/invoices">Invoices</a></li> </ul> </nav> </header> <main> <h1>Invoices</h1> <article> <h2>Invoice 1042</h2> <p>Due on 30 November.</p> </article> </main> <footer> <p>Acme Ltd</p> </footer> </body>Authored expected output: A banner landmark, a named navigation landmark, a single main landmark containing one h1, an article element and a contentinfo landmark.
Each element maps to a landmark role. The aria-label distinguishes this nav from other navigation regions on the same page.
Common misconceptions
#- Every section of a page should be a section element.
- Semantic elements change how the page looks by default.
Follow-up practice
#- html-css-03-inline-semantics
Your progress
#Answers, drafts and completion marks are stored only in this browser. Nothing is sent to a server and no account is used.
Verification: authored. Answers and outputs on this page are authored reference material, not executed results.