- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Add a gray background color to the active link in a default Bootstrap navbar
To add gray background color to the active link, use the .active class in Bootstrap.
You can try to run the following code to implement .active class −
Example
<!DOCTYPE html> <html> <head> <title>Bootstrap Example</title> <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet"> <script src = "/scripts/jquery.min.js"></script> <script src = "/bootstrap/js/bootstrap.min.js"></script> </head> <body> <nav class = "navbar navbar-default"> <div class = "container-fluid"> <div class = "navbar-header"> <a class = "navbar-brand" href = "#">Website</a> </div> <ul class = "nav navbar-nav"> <li class = "active"><a href = "#">Home</a></li> <li><a href = "#">Tutorials</a></li> <li><a href = "#">Quiz</a></li> </ul> </div> </nav> <div class = "container"> <h3>Demo</h3> <p>This is demo text.</p> </div> </body> </html>
- Related Articles
- Add a background color to the active list item in a Bootstrap list group
- Add a grey background color to the Bootstrap 4 card
- Bootstrap navbar-default class
- Create Default Bootstrap Navbar
- Add a light grey background color to the Bootstrap 4 card
- Add a blue background color to simulate a pressed button in Bootstrap
- Add hover color to background color of the table row in Bootstrap
- Add buttons in Bootstrap Navbar
- Add responsive features to Bootstrap navbar
- Add a red background color to an element to set danger action with Bootstrap
- Add a blue background color to an element to set key stuff with Bootstrap
- Add a green background color to an element to set positive action with Bootstrap
- Add a yellow background color to an element to set warning action with Bootstrap
- Change HTML navbar color in Twitter Bootstrap 2.0.4
- Add a background color to the form input with CSS

Advertisements