Menu

How TO – Navbar with Icons


Previous


Next

Learn how to create a responsive navigation menu with icons, using CSS.

Navigation Bar With Icons



Responsive Navigation Bar with Icons

Try to resize the browser window to see the responsive effect.

Home
Search
Contact
Login

Try it Yourself

<!DOCTYPE html>
<html>
<meta name=”viewport” content=”width=device-width, initial-scale=1″>
<link rel=”stylesheet” href=”https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css”>
<style>
body {font-family: Arial, Helvetica, sans-serif;}

.navbar {
width: 100%;
background-color: #555;
overflow: auto;
}

.navbar a {
float: left;
padding: 12px;
color: white;
text-decoration: none;
font-size: 17px;
}

.navbar a:hover {
background-color: #000;
}

.active {
background-color: #04AA6D;
}

@media screen and (max-width: 500px) {
.navbar a {
float: none;
display: block;
}
}
</style>
<body>

<h2>Responsive Navigation Bar with Icons</h2>
<p>Try to resize the browser window to see the responsive effect.</p>

<div>
<a href=”#”><i></i> Home</a>
<a href=”#”><i></i> Search</a>
<a href=”#”><i></i> Contact</a>
<a href=”#”><i></i> Login</a>
</div>

</body>
</html>

Create A Responsive Navbar with Icons

Step 1) Add HTML:

Example

<!– Load an icon library –>
<link rel=”stylesheet” href=”https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css”>

<div class=”navbar”>
  <a class=”active” href=”#”><i class=”fa fa-fw fa-home”></i> Home</a>
  <a href=”#”><i class=”fa fa-fw fa-search”></i> Search</a>
  <a href=”#”><i class=”fa fa-fw fa-envelope”></i> Contact</a>
  <a href=”#”><i class=”fa fa-fw fa-user”></i> Login</a>
</div>

Step 2) Add CSS:

Example

<!DOCTYPE html>
<html>
<meta name=”viewport” content=”width=device-width, initial-scale=1″>
<link rel=”stylesheet” href=”https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css”>
<style>
body {font-family: Arial, Helvetica, sans-serif;}

.navbar {
width: 100%;
background-color: #555;
overflow: auto;
}

.navbar a {
float: left;
padding: 12px;
color: white;
text-decoration: none;
font-size: 17px;
}

.navbar a:hover {
background-color: #000;
}

.active {
background-color: #04AA6D;
}

@media screen and (max-width: 500px) {
.navbar a {
float: none;
display: block;
}
}
</style>
<body>

<h2>Responsive Navigation Bar with Icons</h2>
<p>Try to resize the browser window to see the responsive effect.</p>

<div>
<a href=”#”><i></i> Home</a>
<a href=”#”><i></i> Search</a>
<a href=”#”><i></i> Contact</a>
<a href=”#”><i></i> Login</a>
</div>

</body>
</html>


Previous


Next

Scroll to Top