< Modern HTML >

< nav >

The nav element: not every list of links

A sectioning element for major navigation links. The nav element is one of the most misapplied sectioning elements because the spec is narrower than most developers expect. Not every group of links is a nav. Used precisely, it produces a navigation landmark that assistive technology users can jump to directly, and it pairs with aria-current to give the "you are here" indicator the platform already ships.

Built-in with native HTML

What <nav> actually means

The specification defines nav as a section that links to other pages or to parts within the page: a section with navigation links. The spec is explicit that not every group of links belongs in a nav:

Only sections that consist of major navigation blocks are appropriate for the nav element.

"Major" is the operative word. A paragraph of prose with three inline links is not a nav. A short list of legal links in the footer does not need a nav; the <footer> element alone is enough. A nav is for a navigation block that a reader might reasonably want to skip to, skip past, or return to.

A useful test: would a screen reader user benefit from being able to jump directly to this group of links as a distinct region of the page? If yes, it's a nav. If the links are incidental to the surrounding content, they aren't.

Why the distinction matters: landmarks

Every <nav> produces a navigation landmark. Landmarks are how assistive technology users move through a page at the structural level, the same way sighted users scan for visual anchors.

Marking every list of links as a nav dilutes this. A page with seven nav elements presents seven navigation landmarks, and the list stops being useful. A page with two or three well-chosen navs, each named, presents a clean structural map.

When a page has more than one nav, each one needs an accessible name so landmark lists can distinguish them.

Accessible naming

A nav with a visible heading uses aria-labelledby:

<nav aria-labelledby="primary-nav-heading">
  <h2 id="primary-nav-heading" class="visually-hidden">Primary</h2>
  <ul>
    <li><a href="/">Home</a></li>
    <li><a href="/elements/">Elements</a></li>
    <li><a href="/about/">About</a></li>
  </ul>
</nav>

A nav without a visible heading uses aria-label:

<nav aria-label="Breadcrumb">
  <ol>
    <li><a href="/">Home</a></li>
    <li><a href="/elements/">Elements</a></li>
    <li><a href="/elements/nav/" aria-current="page">nav</a></li>
  </ol>
</nav>

Two conventions worth keeping:

aria-current: the platform's "you are here" indicator

The active link in a nav is the most common place to reach for a JavaScript-driven class toggle. The platform has a dedicated attribute for this.

<nav aria-label="Primary">
  <ul>
    <li><a href="/">Home</a></li>
    <li><a href="/elements/" aria-current="page">Elements</a></li>
    <li><a href="/about/">About</a></li>
  </ul>
</nav>

Valid values for aria-current:

Browsers expose [aria-current] as a CSS attribute selector, so the visual "active" styling can hang off the attribute directly:

nav a[aria-current="page"] {
  font-weight: 600;
  color: CanvasText;
}

One attribute, one CSS rule, one accessible announcement, zero JavaScript state.

Composite patterns where <nav> is the right element

What <nav> is not

A useful test: if the group of links were removed, would a reader lose a way to move through the site or the document? If yes, it's a nav. If the page's structure still makes sense without them, they probably belong in whatever surrounding element they sit inside.

Already HTML-available

Patterns that HTML handles natively, which are often rebuilt in JavaScript:

Invoker commands (command and commandfor) and the broader popover API are the newer of these. Current browser support is worth verifying before relying on them in production.


Reference:

WHATWG
the-nav-element
caniuse.com
mdn-html_elements_nav
MDN Docs
Web/HTML/Element/nav
WAI-ARIA APG
Landmark Regions
Breadcrumb Pattern
ARIA
aria-current