Encodera

Thanks for reading!

Donate to the site — we work hard for you.

HTML & CSS reference

<nav>

A block of main navigation: the site menu, a table of contents, breadcrumbs.

Syntax

<nav><a href="/">Home</a></nav>

Attributes

ParameterTypeDescription
aria-labeltextOptional. The name of the menu when the page has several.

Examples

A menu made of a list of links:

<style>
  nav ul { list-style: none; padding: 0; display: flex; gap: 16px; }
</style>
 
<nav aria-label="Main">
  <ul>
    <li><a href="#">Home</a></li>
    <li><a href="#">Menu</a></li>
    <li><a href="#">Contacts</a></li>
  </ul>
</nav>

Notes

Wrap only major navigation blocks in <nav>, not every group of links. Screen readers let users jump straight to navigation, so when there are several menus, name them with aria-label.

See also

  • <header> — The header of a page or a section: logo, heading, navigation.
  • <ul> — A bulleted list: items whose order does not matter.
  • <a> — A link to another page, a file or a place on the page.

Related recipes

In the tutorial

  • Semantic markup — The neutral div and span and the meaningful header, nav, main, article, section, aside and footer tags for page structure.

Thanks for reading!

Donate to the site — we work hard for you.