/

HTML / CSS / JavaScript Tutorial

HTML Element: <nav>

[this page | pdf | back links]

The HTML <nav> element indicates navigation links. It is new in HTML 5. It is usual not to put all navigation links inside a <nav> element. Instead this element is intended only for major blocks of such links (so that browsers such as for disabled users can use this element to determine when to omit initial rendering of content).

 

The attributes it can take are HTML global attributes and HTML event attributes.

 

To create or access such an element in JavaScript see here. The corresponding HTML DOM object supports standard DOM properties and methods. The default style applicable to this element is shown here.

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
Created using HTML:<br>
<nav>
  <a href="http://www.nematrian.com/IntroductionSoftware.aspx">Software</a>
  | <a href="http://www.nematrian.com/ExpressionEvaluator.aspx">Calculator</a>
</nav>

<br><br>Created using JavaScript:<br>
<span id="element"></span>

<script>
var x = document.createElement("NAV");
var x1 = document.createElement("A");
x1.href = "http://www.nematrian.com/IntroductionSoftware.aspx";
x1.textContent = "Software";
var txt = document.createTextNode(" | ");
var x2 = document.createElement("A");
x2.href = "http://www.nematrian.com/ExpressionEvaluator.aspx";
x2.textContent = "Calculator";
x.appendChild(x1);
x.appendChild(txt);
x.appendChild(x2);
document.getElementById("element").appendChild(x);
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | HTML Elements


Desktop view | Switch to Mobile