Bootstrap Tabs Example: CodePen Live Demos

Ruth Jul 09, 2026

Bootstrap tabs are a versatile and user-friendly way to organize and present content. They allow you to divide your content into separate sections, or tabs, that can be easily switched between. If you're looking for a Bootstrap tabs example, you've come to the right place. Today, we're going to explore a simple yet effective example of Bootstrap tabs using CodePen.

Bootstrap Snippets Library & Layout Examples [Code Demos] | BootstrapCreative
Bootstrap Snippets Library & Layout Examples [Code Demos] | BootstrapCreative

Before we dive into the code, let's briefly discuss why you might want to use Bootstrap tabs. They're perfect for displaying related content that doesn't all need to be shown at once. This could be anything from different sections of a product description to separate steps in a tutorial. By using tabs, you can keep your layout clean and uncluttered, improving the user experience.

Bootstrap 5.3 (2025) Cheat Sheet
Bootstrap 5.3 (2025) Cheat Sheet

Setting Up the Basic Structure

To get started with our Bootstrap tabs example, we first need to include the Bootstrap CSS and JavaScript files in our HTML. You can either download these files or use the CDN links provided by Bootstrap. For this example, we'll use the CDN links.

the different types of font and numbers
the different types of font and numbers

Next, we'll create a basic HTML structure for our tabs. This will include a container div with a class of 'tab-content', and within this, we'll create our tabs and tab panes.

Creating the Tabs

an image of a computer screen with some text on it
an image of a computer screen with some text on it

To create our tabs, we'll use the 'nav' element with the 'nav-tabs' class. Within this, we'll create 'li' elements for each of our tabs. Each 'li' will contain an 'a' element, which will act as the tab itself. The 'data-toggle' attribute with a value of 'tab' is crucial for making these tabs functional.

Here's a simple example of what this might look like:

```html

Modern Tabs Design with pure CSS (HTML/CSS)
Modern Tabs Design with pure CSS (HTML/CSS)

```

Creating the Tab Panes

Next, we'll create our tab panes. These will be contained within the 'tab-content' div we created earlier. Each tab pane will be a 'div' element with the 'tab-pane' class. The 'id' attribute of each 'div' should match the 'href' value of the corresponding 'a' element in our tabs.

Here's an example of what this might look like:

the web breakpoints page is shown in black and white, with different devices on it
the web breakpoints page is shown in black and white, with different devices on it

```html

Home Tab

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero.

Bootstrap 3 grid system explained
Bootstrap 3 grid system explained
A Beginner's Guide to the Latest Bootstrap 5 Utilities
A Beginner's Guide to the Latest Bootstrap 5 Utilities
Bootstrap 5 Classes List Cheat Sheet
Bootstrap 5 Classes List Cheat Sheet
the tailwind css footer is displayed on a webpage with icons and buttons
the tailwind css footer is displayed on a webpage with icons and buttons
Bootstrap Customization: Themes, UI Patterns and Tools
Bootstrap Customization: Themes, UI Patterns and Tools
Thinking in Bootstrap 4, theming with Vartheme BS4 Cheat Sheet
Thinking in Bootstrap 4, theming with Vartheme BS4 Cheat Sheet
26 Best HTML & Bootstrap Footer Templates 2026 - Colorlib
26 Best HTML & Bootstrap Footer Templates 2026 - Colorlib
the wordpress website has two different types of tabs
the wordpress website has two different types of tabs
Bootstrap 5 Classes List Cheat Sheet
Bootstrap 5 Classes List Cheat Sheet
Bootstrap 4 Cheat Sheet - The ultimate list of Bootstrap classes
Bootstrap 4 Cheat Sheet - The ultimate list of Bootstrap classes
How the Bootstrap 4 Grid Works
How the Bootstrap 4 Grid Works
a computer screen with the text dynamic tabs above it and below that reads, remove tabs
a computer screen with the text dynamic tabs above it and below that reads, remove tabs
Bootstrap Accordion Color Change
Bootstrap Accordion Color Change
the bootstrap 3 class list reference page is shown in this screenshote
the bootstrap 3 class list reference page is shown in this screenshote
the guitar tabs are shown in black and white
the guitar tabs are shown in black and white
CSS Tabs with Slide Indicator | Create Tabs using only HTML & CSS
CSS Tabs with Slide Indicator | Create Tabs using only HTML & CSS
Dynamically Filtering Layouts with Isotope & Bootstrap — Speckyboy
Dynamically Filtering Layouts with Isotope & Bootstrap — Speckyboy
25+ Tailwind CSS Button Examples - Stackfindover
25+ Tailwind CSS Button Examples - Stackfindover
CSS3 Tabbed Content
CSS3 Tabbed Content
HTML Tabs Using Radio Input and CSS
HTML Tabs Using Radio Input and CSS

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

```

Adding Interactivity with JavaScript

So far, we've created the basic structure of our tabs, but they're not yet interactive. To make them functional, we need to add some JavaScript. Specifically, we need to initialize the tabs using the 'tab' method provided by Bootstrap.

Here's how you might do this:

```javascript $(document).ready(function(){ $('.nav-tabs a').click(function(e){ e.preventDefault(); $(this).tab('show'); }); }); ```

Using the 'active' Class to Style the Current Tab

By default, Bootstrap will style the current tab with a different background color. However, if you want to customize this, you can use the 'active' class to target the current tab. For example, you might want to change the color of the text or the border of the tab.

Here's an example of how you might do this:

```css .nav-tabs li.active a, .nav-tabs li.active a:focus, .nav-tabs li.active a:hover { border-color: #dddddd; color: #ffffff; background-color: #337ab7; } ```

And that's it! With just a few lines of HTML, CSS, and JavaScript, you've created a functional set of Bootstrap tabs. This is a powerful tool that can greatly improve the user experience on your website. So, why not give it a try on your next project?

Remember, the key to using Bootstrap effectively is to understand its underlying structure and how to customize it to meet your specific needs. With practice, you'll find that Bootstrap can save you a lot of time and effort in your web development projects.

Now that you've seen a simple example of Bootstrap tabs, why not explore some of the other components that Bootstrap has to offer? From buttons and forms to cards and modals, there's a lot to discover. Happy coding!