Code has been added to clipboard!

HTML nav Tag

Reading time 2 min
Published Jun 29, 2017
Updated Oct 2, 2019

HTML nav: Main Tips

  • By using HTML nav tag, you can put a group of links in a single semantic element, making your website more organized.
  • This element is useful for users navigating the main sections of a website.
  • Tables of contents and menus are good examples of HTML nav elements.
  • HTML nav tags can be used in any section of a website.

Using nav in HTML

HTML nav element defines a block of navigational links leading to the main sections of a website:

Example
<nav>
  <ul>
    <li><a href="https://www.bitdegree.org/tag/interactive-learning">Gamified Courses</a></li>
    <li><a href="https://www.bitdegree.org/tutorials">Tutorials</a></li>
    <li><a href="https://www.bitdegree.org/course/learn-solidity-space-doggos">Space doggo course</a></li>
    <li><a href="https://www.bitdegree.org/tag/game-dev">Game Dev Courses</a></li>
  </ul>
</nav>

You should only use the <nav> tag for the dominant block of navigational links, not all the links within a website. It is a great option when you need to include an unordered or ordered list of links. However, if you want to add links to the <footer> element, you don't need to include <nav> tags.

Note: HTML nav element also serves as a navigation landmark for the page. It is useful when addressing accessibility issues: screen readers can use it to allow keyboard navigation to page sections.

Mostly Used <nav> Attributes

HTML nav tag has no specific attributes but supports all the global ones. accesskey, dir, id, and translate are the ones used most often.

accesskey defines a shortcut key to activate or focus an element:

Example
<nav>
 <a href="#main" accesskey="d">First sample</a>
 <a href="#nav" accesskey="h">Second sample</a>
</nav>

dir sets the text direction for the content:

Example
<nav dir="rtl">
  <a href="https://www.bitdegree.org">Home</a>
</nav>

id sets a unique ID for an HTML element:

Example
<nav id="faq">
 <a href="https://www.bitdegree.org/faq">Your questions answered</a>
</nav>

translate identifies whether the content of the element needs to be translated:

Example
<nav translate="lt">
 <a href="https://www.bitdegree.org/courses">Learn With Us!</a>
</nav>

Browser support

Chrome
5+
Edge
All
Firefox
4+
IE
9+
Opera
11.1+
Safari
4.1+

Mobile browser support

Chrome
All
Firefox
4+
Opera
11.1+
Safari
4.2+
Basics
Introduction
Syntax
Editors
Basic Examples
Head Section
<!DOCTYPE>
Tags and Elements
Semantic Elements
Tags Reference
Attributes
Comments
Block and Inline Elements
Forms
Form Elements
Input
Responsive Web Design
Inline Scripts
Uniform Resource Locator
Redirect
XHTML
Geolocation
Drag and Drop
Local Storage
Web Workers
Server-Sent Events
Character Encoding
Text Formatting
Quotation and Citation Elements
Headings
Paragraphs
Links
Tables
Lists
Symbols
Space
Tab
Styles
Computer Code
Layout
Classes
Colors
Images
iframes
Audio Player
Video Player
YouTube Videos
Multimedia
Canvas
SVG
<!-- -->
<a>
<abbr>
<acronym> DEPRECATED
<address>
<applet> DEPRECATED
<article>
<aside>
<audio>
<b>
<base>
<basefont> DEPRECATED
<bdi>
<bdo>
<big> DEPRECATED
<blink> DEPRECATED
<blockquote>
<body>
<br>
<button>
<canvas>
<caption>
<center> DEPRECATED
<cite>
<code>
<col>
<colgroup>
<datalist>
<dd>
<del>
<details>
<dfn>
<dialog>
<dir> DEPRECATED
<div>
<dl>
<dt>
<em>
<embed>
<fieldset>
<figcaption>
<figure>
<font> DEPRECATED
<footer>
<form>
<frame> DEPRECATED
<frameset> DEPRECATED
<h1> – <h6>
<head>
<header>
<hr>
<html>
<i>
<iframe>
<img>
<input>
<ins>
<kbd>
<keygen> DEPRECATED
<label>
<legend>
<li>
<link>
<main>
<map>
<mark>
<menu>
<menuitem> DEPRECATED
<meta>
<meter>
<nav>
<noframes> DEPRECATED
<noscript>
<object>
<ol>
<optgroup>
<option>
<output>
<p>
<param>
<pre>
<progress>
<q>
<rp>
<rt>
<ruby>
<s>
<samp>
<script>
<section>
<select>
<small>
<source>
<span>
<strike> DEPRECATED
<strong>
<style>
<sub>
<summary>
<sup>
<table>
<tbody>
<td>
<tfoot>
<th>
<thead>
<time>
<title>
<tr>
<track>
<tt> DEPRECATED
<u>
<ul>
<var>
<video>
<wbr>