How TO - Pill Navigation
Learn how to create a pill navigation menu with CSS.
Pill Navigation
Create a Pill Navigation
Step 1) Add HTML:
Example
<div class="pill-nav">
<a class="active" href="#home">Home</a>
<a href="#news">News</a>
<a href="#contact">Contact</a>
<a href="#about">About</a>
</div>
Step 2) Add CSS:
Example
/* Style the links inside the pill navigation menu */
.pill-nav a {
display: inline-block;
color: black;
text-align: center;
padding: 14px;
text-decoration: none;
font-size: 17px;
border-radius: 5px;
}
/* Change the color of links on mouse-over */
.pill-nav a:hover {
background-color: #ddd;
color: black;
}
/* Add a color to the active/current link */
.pill-nav a.active {
background-color: dodgerblue;
color:
white;
}
Try it Yourself »
Vertical Pill Navigation
Add display: block
to the links, and they will appear vertically instead of horizontally:
Tip: See also How To Create a Top Navigation Menu.
Tip: Go to our CSS Navbar Tutorial to learn more about navigation bars.