Thuta Learning
HTML
AdvancedWeb DevelopmentBeginner

Header, Nav, Main, Footer

HTMLLesson 2625 min

What you'll walk away with

  • Name the landmark role each page-level layout element produces
  • Keep one visible <main> per page and tell several <nav> elements apart with aria-label
  • Explain why <header>/<footer> are landmarks at body level but not inside an article
  • Choose between <section> (a headed thematic group), <article> (self-contained content) and <div> (a styling wrapper)

Explain it simply

Explain it simply

A shopping mall has a map at the entrance that splits the building into areas such as the entrance, the shops, the food court and the exits, so you can head straight to the part you want. Layout elements are that map for a web page.

<header> is the top of the page, <nav> holds navigation links, <main> is the page's primary content and <footer> is the closing information. Screen reader users jump between these areas, called landmarks, with a shortcut key, reaching the main content without listening to every menu link first.

Problem → Why → Solution

The problem: every wrapper a section, with duplicate navs and mains

Having heard that semantic tags are good, a developer swaps every div for a section and adds a second main inside the sidebar. The page now has two main landmarks, and a screen reader lists two unnamed "navigation" regions, so nobody can tell which is the main menu. The heading-less sections are not meaningful parts at all, just styling boxes.

page.html
<section class="top-bar">
  <section class="logo">Shop</section>
  <nav><a href="/">Home</a> <a href="/sale">Sale</a></nav>
</section>
<main>
  <section class="card">Product list...</section>
</main>
<main class="sidebar">Filters...</main>
<nav><a href="/privacy">Privacy</a></nav>

Why does this happen?

Landmark elements build a map of what parts a page has. There can only be one main content area, so two mains muddle the map, and several unnamed navs cannot be told apart. A section should be a thematic group with its own heading; a box that exists only for CSS should stay a div.

Core concept: landmarks, and when an element becomes one

Most layout elements get a landmark role in the accessibility tree: <nav> becomes navigation, <main> becomes main, <aside> becomes complementary. <header> and <footer> depend on context. At the body level they are the banner and contentinfo landmarks; inside an <article>, <section>, <main>, <aside> or <nav> they are just that part's header or footer and are not landmarks. That is why giving every blog post its own <header> is perfectly fine.

A page should have only one visible <main>: put the page's unique content inside it and keep the header, menus and footer repeated across the site outside. You may have many <nav> elements, but give them names such as aria-label="Main" and aria-label="Footer" so a screen reader announces "Main navigation" and "Footer navigation". Native HTML has no attribute for naming a landmark, which makes this a proper use of ARIA. Not every group of links needs a nav; keep it for major navigation blocks.

An <article> is content that still makes complete sense when lifted out of the page and placed elsewhere, such as in an RSS feed or a share card: a blog post, a product card, a single comment. A <section> is a group about one theme with its own heading, such as "About Us" or "Pricing". A section becomes a region landmark only when it has a name, for example through aria-labelledby; without one it is a plain grouping. An <aside> holds content that is related to the main content but could be removed without hurting it, such as related links or a sidebar.

ElementLandmark roleUse for
<header> (body level)bannerLogo, site title, main menu
<nav>navigationMajor groups of links
<main>mainThe page's unique content (one)
<aside>complementaryRelated side content
<footer> (body level)contentinfoCopyright, contact, policy links
Mental model: a map with named areas
  1. Site-wide parts: header, footer
  2. Navigation blocks: named navs
  3. This page's content: one main
  4. Inside: article and section
  5. Styling only: div

Each landmark is an area on the map: clearly named and never duplicated by accident.

General pattern

html
<header>Site identity <nav aria-label="Main">...</nav></header>
<main>
  <article><h2>Self-contained item</h2>...</article>
  <section aria-labelledby="topic-id"><h2 id="topic-id">Topic</h2>...</section>
  <aside>Related content</aside>
</main>
<footer><nav aria-label="Footer">...</nav></footer>

The site-wide header and footer sit outside main, and all of this page's content lives in one main. Each nav gets an aria-label, and the section is named by its own heading.

Example: a simple page with four landmarks

Without CSS this page looks exactly like a div-based version would. The difference is in the accessibility tree, where four landmarks appear: banner, navigation, main and contentinfo. Compare that with the problem page above, which had two mains.

html
<header>
  <h1>My Website</h1>
  <nav><a href="#home">Home</a> <a href="#about">About</a></nav>
</header>
<main>
  <section id="about">
    <h2>About Us</h2>
    <p>Main content goes here.</p>
  </section>
</main>
<footer>
  <p>&copy; 2026 My Website</p>
</footer>

Code breakdown

  1. Page header<header>

    As a direct child of body it becomes the banner landmark, holding the site title <h1> and the main menu.

  2. Navigation<nav><a href="#home">Home</a> <a href="#about">About</a></nav>

    The navigation landmark. With only one nav on the page a name is optional, but once a footer menu is added it should get aria-label="Main".

  3. Main<main>

    All of the page's unique content lives here. "Skip to content" links usually point at this element.

  4. Section<section id="about">

    A thematic group headed "About Us". Its id is the target of the #about link, and without aria-labelledby it is not a region landmark.

  5. Page footer<footer>

    At body level it is the contentinfo landmark, the place for copyright, contact and policy links.

You should see
A large "My Website" heading appears at the top, the Home and About links sit on one line below it, then the "About Us" heading and the "Main content goes here." paragraph, and "© 2026 My Website" at the bottom. A screen reader's landmark list shows banner, navigation, main and contentinfo.

Articles inside articles

Articles can be nested, and an inner article is understood as related to the outer one. Comments on a blog post are the classic case: each comment is self-contained, with an author, a time and text, yet it responds to the post, so the comments sit inside the post's article under a section headed "Comments".

Skip links: jumping straight to main

Keyboard users have to Tab through every menu link on each new page. A skip link as the first link on the page, pointing at main's id, gets them to the content with one Tab and Enter. A common approach hides it with CSS until it receives focus.

skip-link.html
<body>
  <a href="#content">Skip to main content</a>
  <header>...site menu with many links...</header>
  <main id="content">
    <h1>Page title</h1>
  </main>
</body>

In real projects

Where this shows up in real projects

In frameworks such as Next.js or Astro, a layout component adds the header, nav and footer to every page, and each page component supplies what goes inside <main>. So you write main once in the layout and make sure page components do not add another; a doubled main is a regular code review finding.

On news and e-commerce sites, a listing page contains many <article> cards, each with its own heading, image and link. A product page splits "Description", "Reviews" and "Shipping" into headed sections and puts "You may also like" in an aside. Accessibility audits open the screen reader's landmark list and ask whether the page's map makes sense.

Common mistakes

Common mistakes

1. Making every styling wrapper a section

Wrappers that exist only for CSS, such as a flex container or a card's inner box, should be divs. A pile of heading-less sections makes the document structure noisy and meaningless.

2. Two mains, or the site header inside main

Keep exactly one visible main. Put the site-wide header inside main and the banner landmark disappears, and "skip to main" no longer skips the menu.

3. Several navs with no names

When the header menu, breadcrumb and footer menu are all announced as just "navigation", nobody can tell them apart. Use aria-label="Main", "Breadcrumb" and "Footer", and leave the word "navigation" out of the label because the role already says it.

Best practices

Best practices

  • Start every section with a heading; if there is nothing to call it, ask whether it should be a div.
  • Write main once, in the layout component.
  • Open a screen reader's landmark list and review the page's map at least once.

Mini challenge

Mini challenge: a blog post page

Build a blog post page with the right landmarks. No CSS is needed; focus on the accessibility tree.

  • A site header containing the site name and a nav with aria-label="Main"
  • One main holding an article with its own header (h1 plus the author)
  • Two headed sections inside the article
  • An aside for related posts, and a page footer with a nav labelled "Footer"
post.html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Learning HTML forms - Aye's blog</title>
</head>
<body>
  <!-- TODO: site header with the blog name and the main nav -->
  <!-- TODO: main > article with its own header, then two headed sections -->
  <!-- TODO: aside with links to related posts -->
  <!-- TODO: page footer with a footer nav and a copyright line -->
</body>
</html>

Expected: The landmark list shows banner, navigation "Main", main, complementary, contentinfo and navigation "Footer". The article's header does not appear as a landmark.

Show hint

It is correct that the article's header is not a landmark. The aside can sit inside main or beside it, just not inside the article.

Show solution
post.html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Learning HTML forms - Aye's blog</title>
</head>
<body>
  <header>
    <p>Aye's blog</p>
    <nav aria-label="Main">
      <a href="/">Home</a> <a href="/posts">All posts</a>
    </nav>
  </header>
  <main>
    <article>
      <header>
        <h1>Learning HTML forms</h1>
        <p>By Aye Aye, 9 November 2026</p>
      </header>
      <section>
        <h2>Why labels matter</h2>
        <p>Labels give every field a name.</p>
      </section>
      <section>
        <h2>Validation basics</h2>
        <p>The browser checks required fields for you.</p>
      </section>
    </article>
    <aside>
      <h2>Related posts</h2>
      <a href="/posts/tables">Accessible tables</a>
    </aside>
  </main>
  <footer>
    <nav aria-label="Footer">
      <a href="/privacy">Privacy</a> <a href="/contact">Contact</a>
    </nav>
    <p>© 2026 Aye's blog</p>
  </footer>
</body>
</html>

Quick quiz 1 / 3

In <main><article><header><h2>Post</h2></header>...</article></main>, what role does the <header> get?

Quick quiz 2 / 3

A page has two <nav> elements, a header menu and a footer menu. What should you do?

Quick quiz 3 / 3

When is <section> the right element?

What to remember

  • Body-level header/footer are banner/contentinfo, nav is navigation, main is main and aside is complementary.
  • Keep one visible main and name multiple navs with aria-label.
  • article is self-contained content, section is a headed thematic group, div is a styling wrapper.
  • Headers and footers inside an article are not landmarks, so every post may have its own.

HTML Living Standard — Sections and Semantics — WHATWG

Updated on

Progress is saved only in this browser on this device. It isn't synced to other devices.

Report a problem with this lessonOpens your email app with this lesson's address filled in — nothing is sent until you send it.

Header, Nav, Main, Footer | Thuta Learning