Build Horizontal Navigation Bar with Inline List Items in CSS

Use Inline List Items to build a horizontal navigation bar. Set the <li> elements as inline.


You can try to run the following code to create horizontal navigation bar:

Live Demo

<!DOCTYPE html>
         ul {
            list-style-type: none;
            margin: 0;
            padding: 0;
         .active {
            background-color: #4CAF50;
            color: white;
         li {
            border-bottom: 1px solid #555;
            display: inline;
         <li><a href = "#home">Home</a></li>
         <li><a href = "#company" class="active">Company</a></li>
         <li><a href = "#product">Product</a></li>
         <li><a href = "#services">Services</a></li>
         <li><a href = "#contact">Contact</a></li>