How to Create a Top Navigation Bar in Bootstrap 5 | Bootstrap Tutorial in 2023

Article by: Manish Methani

Last Updated: September 23, 2021 at 2:04pm IST
1 min 21 sec

Bootstrap is a popular front-end framework that can help you create beautiful and responsive websites quickly and easily. In this tutorial, we'll show you how to create a top navigation bar using Bootstrap 5.

Final Output

Step 1: Set up your HTML file

First, create a new HTML file and add the necessary Bootstrap and CSS files. Here's an example:

<!doctype html>
<html lang="en">
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Bootstrap CSS -->
    <link href="" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">

    <title>Bootstrap 5  Navigation Bar </title>

    <script src="" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>


Step 2: Create the navigation bar

Next, add the navigation bar into <body> tag of your HTML file. Here's an example of a basic navigation bar:

    <nav class="navbar navbar-expand-lg navbar-light bg-light">
  <div class="container-fluid">
    <a class="navbar-brand" href="#">Brand Name</a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav me-auto mb-2 mb-lg-0">
        <li class="nav-item">
          <a class="nav-link active" aria-current="page" href="#">Home</a>
        <li class="nav-item">
          <a class="nav-link" href="#">Blog</a>
        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
          <ul class="dropdown-menu" aria-labelledby="navbarDropdown">
            <li><a class="dropdown-item" href="#">CSS Tutor</a></li>
            <li><a class="dropdown-item" href="#">Html coding for website</a></li>
            <li><hr class="dropdown-divider"></li>
            <li><a class="dropdown-item" href="#">Java scripting tutorial </a></li>
        <li class="nav-item">
          <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
      <form class="d-flex">
        <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
        <button class="btn btn-outline-success" type="submit">Search</button>

This navigation bar consists of a brand logo or name, a hamburger menu button, and a list of links. The navbar-expand-lg class makes the navigation bar responsive and collapse into a hamburger menu on smaller screens.

Step 3: Customize the navigation bar

You can customize the navigation bar by adding your own styles or Bootstrap classes. Here are a few examples:

<nav class="navbar navbar-expand-lg navbar-dark bg-dark"> 
  • Change the background color to dark:

Final Output

I hope you got the solid understanding about how to create a top naviagtion bar in bootstrap 5.

Watch Video Tutorials at Codzify YouTube Channel:

Codzify Logo

Terms and Conditions    Cookie Policy   Refund Policy   Adsense Disclaimer