Table of Contents
INTRODUCTION
The HTML <nav> element is used is used to define a section of a webpage that contains navigation links. It helps improve the structure and accessibility of a website. It is generally used to create menus, tables of contents, and indexes.
Example:
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
The concept of the automobile dates back to the 18th century, when inventors experimented with steam-powered vehicles. Some of the key milestones include: 1769 – Nicolas-Joseph Cugnot, a French engineer, built the first self-propelled steam-powered vehicle, primarily used for military purposes.
Usage Guidelines
- Not all links need to be placed within a <nav> element. For ex. the <footer> element in general contains link collection, but do not necessarily require a <nav> element.
- Multiple <nav> elements can exist on a page (e.g. main menu, sidebar, footer navigation).
- The <nav> block generally contains an unordered list (<ul>) of links. With proper CSS it is presented as sidebar, navigation bar, or drop-down menu.
- The <nav> element is intended for providing links, but it doesn't have to be limited to a list; it can also include other types of content like headers, paragraphs and others.
Attributes
The <nav> element only includes global attribute.
Tag Omission
The HTML <nav> element must have both start tag and end tag.
Frequently Asked Questions(FAQ)
Is it mandatory to use the <nav> element for all navigation links?
Can the <nav> element contain elements other than lists?
Can multiple <nav> elements be used within a single HTML document?
What is the difference between <nav> and <menu> in HTML?
Should a <nav> element be outside the <main> element?
Should we put <ul> tag inside <nav> tag?
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>