Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Section that contains only navigation links in HTML5
Navigational links can be provided by using <nav> tag in the document. The links of nav element navigates to other webpages or points to different section of same webpage. Examples of nav element are contents, tables, menus and indexes.
Syntax
Following is the usage of <nav> tag in HTML −
<nav> Links?? </nav>
Example
Following example where we are trying to create a section that contains only navigation links −
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="nav-bar.css">
<h1>TutorialsPoint</h1>
</head>
<body>
<nav>
<ul>
<li>
<a href="#">Home</a>
</li>
<br>
<li>
<a href="#">Tutorials</a>
</li>
<br>
<li>
<a href="#">About</a>
</li>
<br>
<li>
<a href="#">Newsletter</a>
</li>
<br>
<li>
<a href="#">Contact</a>
</li>
</ul>
</nav>
</body>
</html>
Example
Following is another example −
<!DOCTYPE html>
<html>
<head>
<style>
body {
margin: 0px;
padding: 0px;
background-color: grey;
}
ul {
background-color: orange;
text-align: center;
margin: 0px;
padding: 0px;
list-style: none;
}
li {
font-size: 24px;
line-height: 20px;
height: 40px;
padding: 5px;
display: inline-block;
}
a {
text-decoration: none;
color: blue;
}
</style>
</head>
<body>
<center>
<h1>TutorialsPoint</h1>
</center>
<nav>
<ul>
<li>
<a href="#">Home</a>
</li>
<br>
<li>
<a href="#">Tutorials</a>
</li>
<br>
<li>
<a href="#">About</a>
</li>
<br>
<li>
<a href="#">Newsletter</a>
</li>
<br>
<li>
<a href="#">Contact</a>
</li>
</ul>
</nav>
</body>
</html>
Example
In the following example we are creating a menu with navigation links and sub menus(s) −
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>menu</title>
<style type="text/css">
ul {
padding: 0;
list-style: none;
background: #f2f2f2;
}
ul li {
display: inline-block;
position: relative;
line-height: 21px;
text-align: left;
border: 1px solid #5F9EA0;
}
ul li a {
background: #FFF8DC;
display: block;
padding: 8px 25px;
color: #5F9EA0;
text-decoration: none;
}
ul li a:hover {
color: #FFF8DC;
background: #5F9EA0;
}
ul li ul.dropdown {
min-width: 125px;
background: #f2f2f2;
display: none;
position: absolute;
z-index: 999;
left: 0;
}
ul li:hover ul.dropdown {
display: block;
}
ul li ul.dropdown li {
display: block;
}
</style>
</head>
<body>
<ul>
<li>
<a href="Index.html">Home</a>
</li>
<li>
<a href="About.html">About</a>
</li>
<li>
<a href="Contact.html">Contact</a>
</li>
<li>
<a href="shop.html">Shop ▾</a>
<ul class="dropdown">
<li>
<a href="men.html">Mens</a>
</li>
<li>
<a href="women.html">Womens</a>
</li>
<li>
<a href="Accessories.html">Accessories</a>
</li>
</ul>
</li>
</ul>
</body>
</html>
Advertisements
