Master Bootstrap From Scratch

Clear, interactive, and structured Bootstrap lessons designed for beginners and developers.

Bootstrap Breadcrumbs

Learn how to create breadcrumbs in Bootstrap to show the current location of a user within a website.

What are Breadcrumbs?

Breadcrumbs are a navigation component used to show the current location of a user on a website.

They display the path from the home page to the current page. This makes it easier for users to understand where they are and navigate back to previous pages.

Simple Example: Home → Courses → Bootstrap → Breadcrumbs

Why Use Breadcrumbs?

Breadcrumbs are useful when a website contains multiple levels of pages or categories.

  • They show the user's current location.
  • They provide quick navigation to previous pages.
  • They improve the overall user experience.
  • They are useful for websites with many pages.
For example: On a training website, a breadcrumb can show: Home → Courses → Full Stack → Java → Spring Boot

Basic Breadcrumb

Bootstrap provides the .breadcrumb class to create a breadcrumb.

Each individual item is created using the .breadcrumb-item class.

Example:
Code:
<nav aria-label="breadcrumb">

    <ol class="breadcrumb">

        <li class="breadcrumb-item">
            <a href="#">Home</a>
        </li>

        <li class="breadcrumb-item">
            <a href="#">Courses</a>
        </li>

        <li class="breadcrumb-item active"
            aria-current="page">
            Bootstrap
        </li>

    </ol>

</nav>
Simple Explanation: Here, Home and Courses are previous navigation levels, while Bootstrap is the current page.

Breadcrumb Classes

Bootstrap uses specific classes to create breadcrumb navigation.

Class Description
.breadcrumb Creates the breadcrumb container.
.breadcrumb-item Creates an individual breadcrumb item.
.active Indicates the current page.

Active Breadcrumb Item

The current page in a breadcrumb should normally use the .active class.

Example:
<li class="breadcrumb-item active"
    aria-current="page">

    Bootstrap Breadcrumbs

</li>
Note: The active item represents the page that the user is currently viewing.

Multiple Breadcrumb Levels

You can add multiple breadcrumb items when your website has several navigation levels.

Example:
Path: Home → Courses → Full Stack → Java → Spring Boot

Breadcrumb with Links

Previous breadcrumb items can contain links so users can navigate back to those pages.

Example:
Simple Explanation: Users can click Home, Web Development, or Frontend to move back to those sections.

Breadcrumb Accessibility

Bootstrap breadcrumbs can be made more accessible by using the aria-label and aria-current attributes.

<nav aria-label="breadcrumb">

    <ol class="breadcrumb">

        <li class="breadcrumb-item">
            <a href="#">Home</a>
        </li>

        <li class="breadcrumb-item active"
            aria-current="page">
            Bootstrap
        </li>

    </ol>

</nav>
Why? These attributes help screen readers understand the breadcrumb navigation and identify the current page.

Real-World Example

Suppose a student is learning Bootstrap on a training website.

The website can show the following breadcrumb:

This tells the student that Bootstrap is currently open under the Web Development course.

Common Mistakes

  • Forgetting the .breadcrumb class.
  • Forgetting the .breadcrumb-item class.
  • Not using .active for the current page.
  • Adding too many unnecessary breadcrumb levels.
  • Forgetting aria-current="page" for the current page.

Summary

Bootstrap Breadcrumbs are used to show the navigation path of the current page.

  • .breadcrumb creates the breadcrumb container.
  • .breadcrumb-item creates each breadcrumb item.
  • .active identifies the current page.
  • aria-current="page" identifies the current page for accessibility.
  • Breadcrumbs make navigation easier for users.