HTML <nav> tagS2C Home   « HTML <nav> tag

Definition

The <nav> tag is used to define a navigational section for a HTML document.

Use the <nav> tag for grouping together major navigational sections of the page such as site navigation.

If supplying informational links such as sitemaps, contact information, terms of usage etc. then use the <footer> HTML tag instead.

The <nav> tag was introduced in HTML5.

Example


<header style="background-color:cyan">
  <h2>Some heading</h2>
  <p>Header content</p>
</header>
<nav style="background-color:lime">
  <ul>
    <li><a href="../pages/sitemap.html">Sitemap</a></li>
    <li><a href="../pages/linktous.html">Link To Us</a></li>
    <li><a href="mailto:charlie@server2client.com">Contact Us</a></li>
  </ul>
</nav>
<main style="background-color:yellow">
  <h2>Main content heading</h2>
  <p>Main content</p>
</main>
<footer style="background-color:orange">
  <h2>Footer content heading</h2>
  <p>Footer content such as copyright, sitemaps, contact information</p>
</footer>

Some heading

Header content

Main content heading

Main content

Footer content heading

Footer content such as copyright, sitemaps, contact information

Required Attributes

NONE

Optional Attributes

NONE

Global Attributes

Common

accesskey - specifies a keyboard shortcut to an element.


<nav accesskey="a">Content for the navigation</nav>

class - specifies a classname for the element allowing you to apply the style of the predefined class to the content.


<nav class="classname">Content for the navigation</nav>

id - specifies a unique id for the element allowing you to apply the style of the predefined id to the content.


<nav id="idname">Content for the navigation</nav>

style - specifies an inline style for the element allowing you to apply the style to the content.


<nav style="color:red;text-align:left">Content for the navigation</nav>

title - specifies extra information about the content.


<nav title="information about the content">Content for the navigation</nav>

Keyboard

accesskey - specifies a keyboard shortcut to associate with the element.


<nav accesskey="aKeyValue">Content for the navigation</nav>

tabindex - specifies a tab order for the element.


<nav tabindex="someNumber">Content for the navigatione</nav>

Language

dir - specifies the directional flow of the content.


<nav dir="ltr">Content for the navigation</nav>   <!-- The text will flow from left to right -->
<nav dir="rtl">Content for the navigation</nav>   <!-- The text will flow from right to left -->

lang - specifies a language code for the content of the element.


<nav lang="en">Content for the navigation</nav>

xml:lang - specifies a language code for the content of the element in XHTML documents.


<nav xml:lang="fr">Content for the navigation</nav>

spellcheck - specifies whether the element is to have its spelling checked.


<!-- Valid values are true and  false - default is inherited / browser specific. -->
<nav spellcheck="true">Content for the navigation</nav>

translate - specifies whether the content of the element can be translated.


<!-- Valid values are yes and  no - default is yes. -->
<nav translate="no">Content for the navigation</nav> 

Miscellaneous

contenteditable - specifies whether the content of the element is editable.


<!-- Valid values are true and  false - default is inherited. -->
<nav contenteditable="false">Content for the navigation</nav> 

draggable - specifies whether the the element is draggable.

Only text selections, images, and links can be dragged.


<!-- Valid values are true and  false - default is browser specific. -->
<nav draggable="true">Content for the navigation</nav>

hidden - specifies whether the element is not yet, or no longer, relevant.


<!-- Valid values are an empty string or hidden -->
<nav hidden>Content for the navigation</nav> 
<nav hidden="hidden">Content for the navigation</nav> 

Event Attributes

Document

onabort - The JavaScript code to be run on abort.


<nav onabort="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

onerror - The JavaScript code to be run when an error occurs when the file is being loaded.


<nav onerror="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

onload - The JavaScript code to be run when the document is loaded.


<nav onload="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

onresize - The JavaScript code to be run when the browser window is resized.


<nav onresize="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

onscroll - The JavaScript code to be run when the scrollbar of an element is being scrolled.


<nav onscroll="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

onunload - The JavaScript code to be run once a page has unloaded or the browser window has been closed.


<nav onunload="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

Document Element

oncopy - The JavaScript code to be run when the user copies the content of an element.


<nav oncopy="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

oncut - The JavaScript code to be run when the user cuts the content of an element.


<nav oncut="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

onpaste - The JavaScript code to be run when the user pastes some content into an element.


<nav onpaste="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

Drag and Drop

ondrag - The JavaScript code to be run when an element is dragged.


<nav ondrag="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

ondragend - The JavaScript code to be run when an element has stopped being dragged.


<nav ondragend="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

ondragenter - The JavaScript code to be run when an element has been dragged to a valid drop target.


<nav ondragenter="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

ondragleave - The JavaScript code to be run when an element leaves a valid drop target.


<nav ondragleave="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

ondragover - The JavaScript code to be run when an element is being dragged over a valid drop target.


<nav ondragover="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

ondragstart - The JavaScript code to be run at the start of a drag operation.


<nav ondragstart="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

ondrop - The JavaScript code to be run when dragged element is being dropped.


<nav ondrop="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

Form

onblur - The JavaScript code to be run on abort.


<nav onblur="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

onchange - The JavaScript code to be run when object changed and attempt to leave field.


<nav onchange="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

oncontextmenu - The JavaScript code to be run when a context menu is triggered.


<nav oncontextmenu="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

onfocus - The JavaScript code to be run when the element gets focus.


<nav onfocus="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

oninput - The JavaScript code to be run when an element gets user input.


<nav oninput="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

oninvalid - The JavaScript code to be run when an element is invalid.


<nav oninvalid="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

onreset - The JavaScript code to be run when the reset button of a form is clicked.


<nav onreset="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

onselect - The JavaScript code to be run when some or all of the contents of an object are selected.


<nav onselect="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

onsubmit - The JavaScript code to be run when a form is submitted.


<nav onsubmit="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

Keyboard

onkeydown - The JavaScript code to be run when an element is in focus and keyboard key is pressed.


<nav onkeydown="go()">Content for the navigation</nav>   <!-- Executes the go() function -->

onkeypress - The JavaScript code to be run when an element is in focus and keyboard key is pressed down and released.


<nav onkeypress="go()">Content for the navigation</nav>   <!-- Executes the go() function -->

onkeyup - The JavaScript code to be run when an element is in focus and keyboard key is released.


<nav onkeyup="go()">Content for the navigation</nav>   <!-- Executes the go() function -->

Media

oncanplay - The JavaScript code to be run when a file has buffered enough so it is ready to start playing.


<nav oncanplay="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

oncanplaythrough - The JavaScript code to be run when a file can be played all the way to the end without further need of buffering.


<nav oncanplaythrough="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

oncuechange - The JavaScript code to be run when the cue changes when using the track element.


<nav oncuechange="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

ondurationchange - The JavaScript code to be run when the length of the media is changed.


<nav ondurationchange="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

onemptied - The JavaScript code to be run when a media resource element suddenly becomes empty, usually due to an error.


<nav onemptied="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

onended - The JavaScript code to be run when the media has reach the end.


<nav onended="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

onloadeddata - The JavaScript code to be run when media data is loaded and playback can start.


<nav onloadeddata="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

onloadedmetadata - The JavaScript code to be run when metadata has been loaded.


<nav onloadedmetadata="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

onloadstart - The JavaScript code to be run when the media resource has started loading.


<nav onloadstart="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

onpause - The JavaScript code to be run when the media resource has been paused.


<nav onpause="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

onplay - The JavaScript code to be run when the media resource starts playback.


<nav onplay="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

onplaying - The JavaScript code to be run when playback has already begun.


<nav onplaying="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

onprogress - The JavaScript code to be run when the browser is fetching the media data.


<nav onprogress="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

onratechange - The JavaScript code to be run when the playback rate changes.


<nav onratechange="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

onseeked - The JavaScript code to be run when the seeking attribute is set to false indicating that seeking has finished.


<nav onseeked="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

onseeking - The JavaScript code to be run hen the seeking attribute is set to true indicating that seeking is currently active.


<nav onseeking="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

onstalled - The JavaScript code to be run when the browser is unable to continue fetching media data.


<nav onstalled="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

onsuspend - The JavaScript code to be run when media data has stopped before being completely loaded.


<nav onsuspend="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

ontimeupdate - The JavaScript code to be run when the media resources current playback position has changed.


<nav ontimeupdate="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

onvolumechange - The JavaScript code to be run when the volume has changed or been muted.


<nav onvolumechange="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

onwaiting - The JavaScript code to be run when the media resource has paused but is expected to resume.


<nav onwaiting="go()">Content for the navigatione</nav>   <!-- Executes the go() function -->

Mouse

onclick - The JavaScript code to be run when a mouse is clicked on the element.


<nav onclick="go()">Content for the navigation</nav>   <!-- Executes the go() function -->

ondblclick - The JavaScript code to be run when a mouse is double clicked on the element.


<nav ondblclick="go()">Content for the navigation</nav>   <!-- Executes the go() function -->

onmousedown - The JavaScript code to be run when the mouse button is pressed down while the cursor is over the element.


<nav onmousedown="go()">Content for the navigation</nav>   <!-- Executes the go() function -->

onmousemove - The JavaScript code to be run when the mouse button is moved.


<nav onmousemove="go()">Content for the navigation</nav>   <!-- Executes the go() function -->

onmouseout - The JavaScript code to be run when the mouse cursor moves off an element.


<nav onmouseout="go()">Content for the navigation</nav>   <!-- Executes the go() function -->

onmouseover - The JavaScript code to be run when the mouse cursor moves over an element.


<nav onmouseover="go()">Content for the navigation</nav>   <!-- Executes the go() function -->

onmouseup - The JavaScript code to be run when the mouse button is released while the cursor is over the element.


<nav onmouseup="go()">Content for the navigation</nav>   <!-- Executes the go() function -->

onwheel - The JavaScript code to be run when the mouse wheel rolls up or down over an element.


<nav onwheel="go()">Content for the navigation</nav>   <!-- Executes the go() function -->

Window

NONE

go to home page Homepage go to top of page Top