October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

Build Free Bootstrap Tabs That Switch Panels and Work With a Keyboard

Learn how to build Bootstrap 5 tabs that switch local panels, load the tab plugin, and support keyboard navigation with connected accessible markup.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Bootstrap’s .nav-tabs class styles a tab bar; it does not switch local content by itself. For working tabs, connect each button to a panel and load Bootstrap’s tab JavaScript plugin. This example uses Bootstrap 5.3.8, the version shown in the official Bootstrap 5.3 setup instructions.

Start with working Bootstrap 5 tabs

Use buttons for controls that reveal local panels. Each button’s data-bs-target must match its panel’s ID, and each panel’s aria-labelledby must point back to its button. Keep one tab and its panel active when the page loads.

As an Amazon Associate I earn from qualifying purchases.

<div class="container mt-4">
  <ul class="nav nav-tabs" id="example-tabs" role="tablist">
    <li class="nav-item" role="presentation">
      <button class="nav-link active"
              id="overview-tab"
              data-bs-toggle="tab"
              data-bs-target="#overview"
              type="button"
              role="tab"
              aria-controls="overview"
              aria-selected="true">
        Overview
      </button>
    </li>
    <li class="nav-item" role="presentation">
      <button class="nav-link"
              id="details-tab"
              data-bs-toggle="tab"
              data-bs-target="#details"
              type="button"
              role="tab"
              aria-controls="details"
              aria-selected="false">
        Details
      </button>
    </li>
  </ul>

  <div class="tab-content" id="example-tabs-content">
    <div class="tab-pane fade show active"
         id="overview"
         role="tabpanel"
         aria-labelledby="overview-tab"
         tabindex="0">
      <p>Overview content goes here.</p>
    </div>
    <div class="tab-pane fade"
         id="details"
         role="tabpanel"
         aria-labelledby="details-tab"
         tabindex="0">
      <p>Details content goes here.</p>
    </div>
  </div>
</div>

The key connections are the #overview target and overview panel ID, and the corresponding pair for Details. The IDs must be unique on the page. Bootstrap’s .tab-content and .tab-pane classes handle panel presentation, while .nav-tabs supplies the familiar tab styling.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Load Bootstrap CSS and tab JavaScript

The example needs Bootstrap’s CSS for its layout and appearance and the tab plugin for switching panels. The official Bootstrap 5.3 quick start documents version 5.3.8 and provides matching CDN URLs and integrity values. Copy the CSS and JavaScript tags from that setup page into your HTML, preserving their integrity attributes and crossorigin="anonymous" settings: Bootstrap 5.3 quick start.

For JavaScript, use the documented compiled bootstrap.bundle.min.js asset, which includes the plugins, or load the tab plugin individually if your project manages Bootstrap components separately. Put the script before the closing </body> tag, or otherwise ensure it loads after the tab markup. The data-bs-toggle="tab" attributes let Bootstrap activate the interaction without custom event-handling code.

If your project already has Bootstrap, check its version and use documentation and assets that match it. The CDN tags on the 5.3 setup page are specifically for Bootstrap 5.3.8; do not mix CSS and JavaScript files from different versions.

Choose tabs only for local content switching

Use tab semantics when activating a control changes which panel is shown in the current view. If each item takes the visitor to another page, it is navigation, not a tab interface—even if the links are styled to look like tabs. In that case, use normal navigation markup and do not assign role="tab" or role="tablist".

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Bootstrap also supports pill styling with its navigation classes. Choose tabs or pills for the visual treatment that suits the interface; the appearance does not change the need for the same trigger-to-panel connections and accessible state.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Check keyboard behavior and panel focus

Bootstrap’s tab plugin manages the selected state and roving focus: the active tab is the one reached by normal Tab navigation, while arrow keys move among tabs. Home moves focus to the first tab and End to the last. Bootstrap documents Up and Left as moving to the prior tab, and Down and Right as moving to the next; its plugin does not vary arrow-key direction according to whether the tab bar is horizontal or vertical.

The panel’s tabindex="0" makes it reachable by keyboard when a visitor tabs onward from a selected tab. If the panel begins with a meaningful focusable control, such as a link or button, that child may already provide an appropriate next focus target; assess the panel’s content rather than adding focus stops automatically.

  • Give every tab a unique ID and a matching panel target.
  • Set aria-controls on each tab to its panel ID and aria-labelledby on each panel to its tab ID.
  • Mark only the initially selected tab with aria-selected="true" and the active classes; the other tabs start unselected.
  • Test arrow-key movement, Home and End, and the transition from the tab to the panel’s content.

Avoid dropdowns inside tab interfaces

Bootstrap states that its tab JavaScript plugin does not support tabbed interfaces containing dropdown menus because of usability and accessibility issues. Keep dropdown menus outside the tab interface rather than nesting them among its tab controls or panels. See the Bootstrap 5.3 navs and tabs documentation for the component’s markup and interaction details.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.