Solution 1 :

You can use active class for the nav-link. As per the documentation,

Add the .active class on .nav-link to indicate the current page.

Refer more here

In your example if you want the nav-link “Accueil” to be highlighted if the user is in index.php add the active class in the HTML as below.

 <li class="nav-item"> 
     <a class="nav-link active" href="index.php">Accueil</a>
 </li>

Try the following snippet

#nav li a:hover {
  background-color: #87CEEB;
}
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous">
<div id="nav">
  <ul class="nav nav-pills">
    <li class="nav-item"> <a class="nav-link active" href="index.php">Accueil</a></li>
    <li class="nav-item"> <a class="nav-link" href="compotest.php">Assistance</a></li>
    <li class="nav-item"> <a class="nav-link" href="evenementsVU.html">Evènements</a></li>
    <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Bulletins</a>
      <div class="dropdown-menu">
        <a class="dropdown-item" href="bulletin125.htm">Dernier bulletin</a> <a class="dropdown-item" href="collection.php">Bulletins archivés</a>

    </li>
    <li class="nav-item"> <a class="nav-link" href="inscriptionform.php">Adhésion</a> </li>
    <li class="nav-item"> <a class="nav-link" href="contact.php">Contact</a> </li>
    <li class="nav-item"> <a class="nav-link" href="liens.php">Liens</a> </li>
  </ul>
</div>

Solution 2 :

<ul class="nav nav-pills">
    <li class="active"><a data-toggle="pill" href="#home">Home</a></li>
    <li><a data-toggle="pill" href="#menu1">Menu 1</a></li>
    <li><a data-toggle="pill" href="#menu2">Menu 2</a></li>
    <li><a data-toggle="pill" href="#menu3">Menu 3</a></li>
  </ul>
  
  <div class="tab-content">
    <div id="home" class="tab-pane fade in active">
      <h3>HOME</h3>
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>
    <div id="menu1" class="tab-pane fade">
      <h3>Menu 1</h3>
      <p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
    </div>
    <div id="menu2" class="tab-pane fade">
      <h3>Menu 2</h3>
      <p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam.</p>
    </div>
    <div id="menu3" class="tab-pane fade">
      <h3>Menu 3</h3>
      <p>Eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.</p>
    </div>
  </div>
</div>

Problem :

I started working on DW (last version), (I used bootstrap component: “basic navbar” to insert the menu)
but I realize as soon as I click on a tab, it loads the page for me, but the tab does not remain highlighted.

Rem: (the “hover” works very well): as soon as I hover over the tabs the color changes well,
and so I would like it to keep for example this same color when the tab remains active so that the user knows
in which menu it is found.
I posted the code (generated by DW) but I’m not sure what to change in the code ??? and in the css?
Surprising all the same that this basic principle is not set by default in the component ??
In my css I just have the “hover” part.

Thank you for your advice because I’ve been struggling with this pb for several days (yet it seems to me to be a fairly common behavior … !!!)

#nav li a:hover {
  background-color: #87CEEB;
}
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous">
<div id="nav">
  <ul class="nav nav-pills">
    <li class="nav-item"> <a class="nav-link" href="index.php">Accueil</a></li>
    <li class="nav-item"> <a class="nav-link" href="compotest.php">Assistance</a></li>
    <li class="nav-item"> <a class="nav-link" href="evenementsVU.html">Evènements</a></li>
    <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Bulletins</a>
      <div class="dropdown-menu">
        <a class="dropdown-item" href="bulletin125.htm">Dernier bulletin</a> <a class="dropdown-item" href="collection.php">Bulletins archivés</a>

    </li>
    <li class="nav-item"> <a class="nav-link" href="inscriptionform.php">Adhésion</a> </li>
    <li class="nav-item"> <a class="nav-link" href="contact.php">Contact</a> </li>
    <li class="nav-item"> <a class="nav-link" href="liens.php">Liens</a> </li>
  </ul>
  </div>

Comments

Comment posted by my solution

If I have understood you correct, you want the link to be highlighted on the page where user is in. Try out

Comment posted by Jean

Avec votre solution, il me montre l’onglet actif par défaut mis en surbrillance mais dès que je clique sur un autre onglet, il ne le conserve pas. Pourquoi mon code est-il devenu illisible, les caractères semblent être dupliqués ???

Comment posted by Rifky Niyas

Can you please say that in english please?

Comment posted by Rifky Niyas

What I mean by replace is this. According to your code sample, In your navbar code in

Comment posted by upvoting and accepting the answer

If you find my answer useful and it solves your problem consider

Comment posted by Jean

Thank you for your answer!!! Indeed, it works for tabs: as soon as I change tab, this time it remains well highlighted but my pages are not loaded … I did not quite understand the fact of adding the “#” before the names of my pages to load but how can he load them in this case??? or there’s something I really didn’t understand??? I posted you my code readapted according to your template (only for the first 3 tabs)

By