A breadcrumb is a visual component that displays the current page's location within a hierarchical structure. For example:
We implement the breadcrumb as an ordered list using the <ol>
tag within a <nav>
tag. The generalized syntax is as follows:
<nav><ol class="breadcrumb"><li class="breadcrumb-item"><a href="#"> Item </a></li><li class="breadcrumb-item active"> Current Item </li><ol></nav>
The ordered list element uses the breadcrumb
class, while each item in the list uses the breadcrumb-item
class. Each list item also contains a hyperlink to its respective web page.
For the final item in the breadcrumb, we use the active
class in addition to the breadcrumb-item
class. We don't create a hyperlink for the last item as the user is already on the concerned page. The active
class differentiates the styling for this item, making the current page easily identifiable.
<nav>
tag to contain the breadcrumb. The aria-label
is set to "breadcrumb" to let assistive technologies, like screen readers. Please know that the web page will display a breadcrumb.<ol>
tag. We use the breadcrumb
class provided by bootstrap, which provides the necessary styling for the separators.<li>
tag. We hyperlink each item to its respective web page using an <a>
tag.<li>
tag to create the last item on our breadcrumb or current page. We include the active
class so that the current page is visually discernible. Finally, the aria-current
attribute is set to "page" to indicate that this item refers to the current page. Note: Click here to learn more about ARIA in HTML.
Bootstrap allows us to choose custom separators. These custom separators can be a string or an
We'll use the custom style property --bs-breadcrumb-divider
on the <nav>
tag to specify the new separator.
We can set the separator between breadcrumb items to any string in the following manner:
--bs-breadcrumb-divider
style property is set to '=>' using inline CSS. We can also set the separator to a custom SVG element, such as a simple horizontal line. We have placed the SVG code as a separate CSS class for simplicity.
custom-divider
class within the <style>
tag. In this class, we set the --bs-breadcrumb-divider
property to a reference to an SVG element.<nav>
tag.Note: Click here to learn more about the HTML SVG element.
Free Resources