Often contains the primary navigation. Learn more →
<nav> ElementThe <nav> element represents a section of a page that contains navigation links, either to other pages or to parts within the current page. Not all groups of links need to be in a <nav> element—only sections that consist of major navigation blocks are appropriate for this element.
<nav> <!-- Navigation links --></nav>The <nav> element has no element-specific attributes.
This element supports all global attributes.
The most common use is for the main site navigation menu:
A navigation menu with dropdown submenus:
Breadcrumbs showing the user’s location in the site hierarchy:
Navigation for jumping to different sections of a long document:
Secondary navigation in the footer:
Navigation for multi-page content:
Responsive navigation with hamburger menu:
When you have multiple <nav> elements, use aria-label or aria-labelledby to distinguish them:
<!-- Good: Labeled navigation --><nav aria-label="Primary"> <ul> <li><a href="/">Home</a></li> <li><a href="/about">About</a></li> </ul></nav>
<nav aria-label="Footer"> <ul> <li><a href="/privacy">Privacy</a></li> <li><a href="/terms">Terms</a></li> </ul></nav>
<!-- Or use aria-labelledby --><nav aria-labelledby="primary-nav-heading"> <h2 id="primary-nav-heading">Main Menu</h2> <ul>...</ul></nav>Not every group of links needs to be in a <nav> element:
<!-- Good: Major navigation blocks only --><nav aria-label="Primary"> <a href="/">Home</a> <a href="/products">Products</a></nav>
<main> <p>Visit our <a href="/store">store</a> or <a href="/support">support</a> pages.</p> <!-- Inline links don't need <nav> --></main>
<footer> <p>© 2025 | <a href="/privacy">Privacy</a> | <a href="/terms">Terms</a></p> <!-- Simple footer links may not need <nav> --></footer>
<!-- Use <nav> for substantial link groups --><footer> <nav aria-label="Footer"> <ul> <li><a href="/about">About</a></li> <li><a href="/careers">Careers</a></li> <li><a href="/press">Press</a></li> <li><a href="/privacy">Privacy</a></li> </ul> </nav></footer>Structure navigation links with lists for better accessibility:
<!-- Good: List structure --><nav aria-label="Primary"> <ul> <li><a href="/">Home</a></li> <li><a href="/about">About</a></li> <li><a href="/contact">Contact</a></li> </ul></nav>
<!-- Acceptable but less semantic --><nav aria-label="Primary"> <a href="/">Home</a> <a href="/about">About</a> <a href="/contact">Contact</a></nav>Mark the current page in navigation:
<nav aria-label="Primary"> <ul> <li><a href="/">Home</a></li> <li><a href="/about" aria-current="page">About</a></li> <li><a href="/contact">Contact</a></li> </ul></nav>The <nav> element creates a navigation landmark that assistive technologies can identify and navigate to:
<!-- Creates a navigation landmark --><nav aria-label="Primary navigation"> <ul> <li><a href="/">Home</a></li> </ul></nav>Screen reader users can jump between navigation landmarks using keyboard shortcuts:
Provide skip links for keyboard users to bypass navigation:
Ensure all navigation items are keyboard accessible:
<nav aria-label="Primary"> <button aria-expanded="false" aria-controls="menu"> Menu </button> <ul id="menu" hidden> <li><a href="/">Home</a></li> <li><a href="/about">About</a></li> </ul></nav>
<script> // Ensure Enter and Space keys work on buttons // Ensure Escape closes menus // Ensure Tab navigates through items</script>Use aria-current to indicate the current page or location:
<nav aria-label="Breadcrumb"> <ol> <li><a href="/">Home</a></li> <li><a href="/products">Products</a></li> <li><a href="/products/laptops" aria-current="page">Laptops</a></li> </ol></nav>Values for aria-current:
page - Current pagestep - Current step in a processlocation - Current location in a hierarchydate - Current date in a calendartime - Current timetrue - Current item in a set| Browser | Version |
|---|---|
| Chrome | 5+ |
| Firefox | 4+ |
| Safari | 5+ |
| Edge | All versions |
| IE | 9+ |
Often contains the primary navigation. Learn more →
May contain secondary navigation. Learn more →
Anchor elements create navigation links. Learn more →
Similar but for toolbars and context menus. Learn more →
<!-- Wrong: Nav for every group of links --><p>Check out our <nav><a href="/blog">blog</a></nav> for updates.</p>
<footer> <nav> <a href="/privacy">Privacy</a> </nav></footer>
<!-- Correct: Nav for major navigation blocks --><nav aria-label="Primary"> <a href="/">Home</a> <a href="/blog">Blog</a> <a href="/contact">Contact</a></nav>
<p>Check out our <a href="/blog">blog</a> for updates.</p>
<footer> <p><a href="/privacy">Privacy</a> | <a href="/terms">Terms</a></p></footer><!-- Wrong: Multiple navs without labels --><nav> <a href="/">Home</a></nav><nav> <a href="/privacy">Privacy</a></nav>
<!-- Correct: Label each nav --><nav aria-label="Primary"> <a href="/">Home</a></nav><nav aria-label="Footer"> <a href="/privacy">Privacy</a></nav><!-- Incomplete: No current page indicator --><nav> <a href="/">Home</a> <a href="/about">About</a></nav>
<!-- Better: Mark current page --><nav> <a href="/">Home</a> <a href="/about" aria-current="page">About</a></nav>