w3resource
HTML exercises

HTML CSS Exercise: CSS Navigation bar

Solution:

HTML Code:

<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset=utf-8>
<title>HTML CSS exercise - create a simple navigaiton bar</title>
<style type="text/css">
nav {
display: block;
position: absolute;
top: 0;
width: 100%;
background-color: green;
}
li{
list-style-type: none;
display: inline;
margin-right: 20px;
font-size:25px
}
a:link {
color: #fff;
text-decoration: none;
}
a:hover {
color: orange;
text-decoration: none;
}
li > ul {
display: none
}
li:hover ul {display: block; position: absolute; left:200px;background-color:green;margin:0;}
li:hover ul li a:link{display: block;margin-left:-30px;}
</style>
</head>
<body>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li>
<a href="#">Products</a>
<ul>
<li><a href="#">Engineering</a></li>
<li><a href="#">Telecom</a></li>
<li><a href="#">Energy</a></li>
<li><a href="#">Finance</a></li>
<li><a href="#">Consultancy</a></li>
</ul>
</li>
<li><a href="#">Services</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</body>
</html>

Live Demo :

See the Pen navigation-answer by w3resource (@w3resource) on CodePen.


Supported browser

Firefox logo Chrome logo Opera logo Safari logo Internet Explorer logo
YesYesYesYesYes

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming


bedava porno