htmlcsstwitter-bootstrapfrontendnavbar

Need to give a color to a menu link in html css


Please find the code for navbar below. How can I give the color to the html link like Home, Services and About?

   <!--navbar-->
   <nav class="navbar navbar-expand-lg navbar-light bg-light">
   <div class="container-fluid">
    
    <div class="navimg">
    
      <img src="./img/Heliosupdated.png" alt="Description">

    </div>
    
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-                 target="#navbarNav"
      aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
     /button>
     <div class="collapse navbar-collapse" id="navbarNav">
      <ul class="navbar-nav">
        <li class="nav-item">
          <a class="nav-link active" aria-current="page" href="#">Home</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Services</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">About</a>
        </li>

     </ul>
    </div>
    </div>
    </nav>

I am expecting the color to be changed once the external CSS is being applied.

I tried to give this external css as mentioned below, I have tried to change the color. It won't affect without adding an important! in the code.

.nav-link active a {
   color:#2762AC;
}

Please find the css below,

.navbar-nav {
    margin-left: auto;
}


.nav-link active a {
    color:#2762AC !important;
  }


/*Navbar style*/


/* end of Navbar style*/
/* end of Navbar style*/


#navbarNav{
    
    padding-top: 70px;
    padding-right: 240px;

}

.navimg img{
    width:100%;
    height: 97px;
}

Solution

  • use !important in your external css file

    .nav-link active a {
      color:#2762AC !important;
    }