Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • BS5 Tutorial
  • BS5 Interview Questions
  • BS5 Layout
  • BS5 Content
  • BS5 Components
  • BS5 Helpers
  • BS5 Utilities
  • BS4 Tutorial
  • BS Tutorial
  • Bootstrap Cheatsheet
  • Tailwind
  • CSS Frameworks
  • HTML Formatter
Open In App
Next Article:
How to force tab-navigation to stay in place using Bootstrap ?
Next article icon

How to force tab-navigation to stay in place using Bootstrap ?

Last Updated : 05 May, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

Tab-navigation: Tabs are made with <ul class="nav nav-tabs"> and we use the <li class="active"> element to mark the current page. To fix the position of navigation tab style, position: fixed; property is used.

Syntax:

<ul class="nav nav-tabs" id="myTab" role="tablist">     <li class="nav-item">         <a class="nav-link active" href="#home" data-toggle="tab">Home</a>     </li>     . . . </ul> <div class="tab-content">     <div class="tab-pane fade show active" id="home">content....</div>     . . . </div>

Example:

HTML
<!DOCTYPE html> <html lang="en"> <head>     <!-- Required meta tags -->     <meta charset="utf-8">     <meta name="viewport" content="width=device-width,             initial-scale=1, shrink-to-fit=no">     <!-- Bootstrap CSS -->     <link rel="stylesheet" href= "https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"         integrity= "sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk"          crossorigin="anonymous">     <script src= "https://kit.fontawesome.com/577845f6a5.js"          crossorigin="anonymous">     </script>     <!-- Optional JavaScript -->     <!-- jQuery first, then Popper.js, then Bootstrap JS -->     <script src= "https://code.jquery.com/jquery-3.5.1.slim.min.js"         integrity= "sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"          crossorigin="anonymous">     </script>     <script src= "https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"         integrity= "sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"          crossorigin="anonymous">     </script>     <script src= "https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"         integrity= "sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI"          crossorigin="anonymous">     </script>     <style type="text/css">         /* To stay in place use position property */         .nav {             position: fixed;             background-color: lightgreen;         }     </style> </head> <body>     <br>     <nav class="container">         <ul class="nav nav-tabs">             <li class="nav-item">                 <a class="nav-link active" href="#html"                      data-toggle="tab">                     <b>HTML</b>                 </a>             </li>             <li class="nav-item">                 <a class="nav-link" href="#css"                      data-toggle="tab">                     <b>CSS</b>                 </a>             </li>             <li class="nav-item">                 <a class="nav-link" href="#contactus"                      data-toggle="tab">                     <b>Contact</b>                 </a>             </li>         </ul>     </nav>     <!-- Tab content -->     <div class="tab-content">         <div class="container tab-pane active" id="html">             <h3 style="color: green">GeeksforGeeks</h3>             <h3>HTML Introduction</h3>              <p>                 HTML stands for Hyper Text Markup Language.                 It is used to design web pages using markup                 language. HTML is the combination of Hypertext                 and Markup language. Hypertext defines the link                 between the web pages. Markup language is used                 to define the text document within tag which                 defines the structure of web pages. This language                 is used to annotate (make notes for the computer)                 text so that a machine can understand it and                 manipulate text accordingly. Most of markup                 (e.g. HTML) languages are human readable.                 Language uses tags to define what manipulation                 has to be done on the text.             </p>          </div>         <div class="container tab-pane" id="css">             <h3 style="color: green">GeeksforGeeks</h3>             <h3>CSS Introduction</h3>              <p>                 Cascading Style Sheets, fondly referred to as CSS,                 is a simply designed language intended to simplify                 the process of making web pages presentable. CSS                 allows you to apply styles to web pages. More                 importantly, CSS enables you to do this independent                 of the HTML that makes up each web page. CSS is easy                 to learn and understood but it provides powerful                 control over the presentation of an HTML document.             </p>          </div>         <div class="container tab-pane" id="contactus">             <h3 style="color: green">GeeksforGeeks</h3>             <h3>Contact Form</h3>             <form>                 <div class="form-group row">                     <label for="em" class="col-12 col-md-2                         col-form-label">                           Email ID:                       </label>                     <div class="col-4">                         <input type="text" class="form-control"                              id="em" name="em" placeholder="Email">                     </div>                 </div>                 <div class="form-group row">                     <label for="ym" class="col-12 col-md-2                         col-form-label">                           Your Message:                       </label>                     <div class="col-4">                         <input type="text" class="form-control"                              id="ym" name="ym" placeholder="Your message..">                     </div>                 </div>                 <div class="form-group row">                     <div class="offset-md-2 col-md-10">                         <button type="submit" class="btn btn-primary">                             Submit                         </button>                     </div>                 </div>             </form>         </div>     </div> </body> </html> 

Output:


Next Article
How to force tab-navigation to stay in place using Bootstrap ?

S

swapnitanerkar28
Improve
Article Tags :
  • Web Technologies
  • HTML
  • CSS
  • Bootstrap
  • Bootstrap-4

Similar Reads

    How to create a navigation bar using React-Bootstrap?
    React-Bootstrap is a front-end framework that was designed with React in mind. The NavBar Component is a navigation header that is responsive and powerful. It supports navigation, branding, and many other related features. In this article, we are going to implement a navigation bar using React Boots
    2 min read
    How to create a tabbed navigation menu in Bootstrap?
    A navigation bar is used in every website to make it more user-friendly so that the navigation through the website becomes easy and the user can directly search for the topic of their interest. The navigation bar is placed at the top of the page.Tab-based navigations are one of the most effective wa
    2 min read
    How to create Responsive Bottom Navigation Bar using Bootstrap ?
    A navigation bar is used in every website to make it more user-friendly so that the navigation through the website becomes easy and the user can directly search for the topic of their interest. The word "Navigation" means the science of moving from one place to another. In this article, we create a
    5 min read
    How to create a Pills navigation menu in Bootstrap?
    In this article, we will learn how to make a Pills navigation menu in Bootstrap 5. Pills are a great navigation style to implement for your websites as it enhances the user experience and navigation flow of your website. Creating a pills navigation menu is simple and easy, all you have to do is to i
    7 min read
    How to create a tabbed pills and vertical pills navigation menu in Bootstrap ?
    In this article, we will learn about tabbed pills and the vertical pills navigation menu in Bootstrap, & will understand their implementation through the examples. These kinds of navigation menus are used to decorate the navbar in a different fashion with a specific distinct navigation style to
    4 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences