Sub topic 2
Navigation Inside a Web Page
Assume you know basic HTML tags, CSS selectors, and how to inspect a page in browser developer tools. This chapter focuses on how the header, hero, content sections, and footer connect.
Navigation Inside the Header
A header usually identifies the site and provides its primary navigation. Use <nav> for a group of major navigation links. Give it an accessible name so screen reader users can distinguish it from other navigation regions.
<header>
<a href="/">Acme Bakery</a>
<nav aria-label="Primary">
<ul>
<li><a href="/menu">Menu</a></li>
<li><a href="/about">About</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
</nav>
</header>Keep navigation links focused on major destinations. Use lists because the links form a related collection. A footer can contain a separate navigation group with a different label.
The Hero: The First Message
The hero is the first prominent section in the main content. It should communicate the page's main purpose quickly. Use one <h1> for the page, supporting text, and one clear call to action.
<section class="hero" aria-labelledby="hero-title">
<div>
<h1 id="hero-title">Fresh bread, baked every morning</h1>
<p>Order ahead and pick up warm loaves on your way to work.</p>
<a href="/menu">See the menu</a>
</div>
<img src="/images/hero-loaf.jpg"
alt="A basket of freshly baked loaves"
width="800"
height="600"
fetchpriority="high">
</section>The width and height attributes reserve image space while it loads. This helps prevent the page from shifting.
Content Sections
Place the page's supporting messages after the hero inside <main>. Give each meaningful section a heading. Use <h2> for sections directly under the page's <h1>.
<section>
<h2>Our specialties</h2>
<p>Sourdough, rye, and seasonal pastries.</p>
</section>A heading hierarchy helps users scan the page and gives assistive technology an outline.
The Footer
The footer closes the page with ownership information, contact details, or secondary links.
<footer>
<p>© 2026 Acme Bakery</p>
<nav aria-label="Footer">
<a href="/privacy">Privacy</a>
<a href="/contact">Contact</a>
</nav>
</footer>Exercise
Which element should contain the page's primary navigation, and how should it be named?
Show answer
Put the links inside a nav element and give it an accessible name such as aria-label="Primary".