How to Create Nav Pills

Pills are created with <ul class="nav nav-pills">.

To make the Pills toggleable, add the data-toggle="pill" attribute to each link. Then add a .tab-pane class with a unique ID for every tab and wrap them inside a <div> element with class .tab-content.

<!DOCTYPE html>

<html lang="en">

<head>

 <title>Bootstrap Example</title>

 <meta charset="utf-8">

 <meta name="viewport" content="width=device-width, initial-scale=1">

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>

  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>

</head>

<body>


<div class="container">

 <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>Content Here</p>

  </div>

  <div id="menu1" class="tab-pane fade">

   <h3>Menu 1</h3>

   <p>Content</p>

  </div>

  <div id="menu2" class="tab-pane fade">

   <h3>Menu 2</h3>

   <p>Content</p>

  </div>

  <div id="menu3" class="tab-pane fade">

   <h3>Menu 3</h3>

   <p>Content</p>

  </div>

 </div>

</div>


</body>

</html>

Sign In or Register to comment.