totn HTML

HTML: <nav> tag

This HTML tutorial explains how to use the HTML element called the <nav> tag with syntax and examples.

Description

The HTML <nav> tag is an HTML5 element that defines a section with navigation links in the HTML document. This tag is also commonly referred to as the <nav> element.

Syntax

In HTML, the syntax for the <nav> tag is:

<body>
<nav>
  <ul>
    <li><a href="/section1/index.html">Section1</a></li>
    <li><a href="/section2/index.html">Section2</a></li>
    <li><a href="/section3/index.html">Section3</a></li>
  </ul>
</nav>
</body>

Attributes

Only the Global Attributes apply to the <nav> tag. There are no attributes that are specific to the <nav> tag.

Note

  • The HTML <nav> element is an HTML5 element that is found within the <body> tag.
  • The <nav> tag is used to create navigation in the HTML document.
  • For IE browsers older than IE 9, use HTML5shiv which is a javascript workaround to provide support for the new HTML5 elements such as: <header>, <main>, <article>, <section>, <aside>, <nav>, <footer>.

Browser Compatibility

The <nav> tag has basic support with the following browsers:

  • Chrome 5+
  • Android 2.2+
  • Firefox 4.0+ (Gecko 2.0+)
  • Firefox Mobile 4.0+ (Gecko 2.0+)
  • Internet Explorer 9.0+ (IE 9.0+)
  • IE Phone 9.0+
  • Opera 11.10+
  • Opera Mobile 11.0+
  • Safari 4.1+ (WebKit)
  • Safari Mobile 5.0+ (iOs 4.2+)

Example

We will discuss the <nav> tag below, exploring examples of how to use the <nav> tag in HTML5, HTML 4.01 Transitional, XHTML 1.0 Transitional, XHTML 1.0 Strict, and XHTML 1.1.