Bootstrap 4 Default Breadcrumb
Easily add default breadcrumbs to your website with Bootstrap 4. Learn how to provide clear navigation paths for users to track their location and easily navigate back through pages.
-
-
Preview
-
Code
-
Discover how to integrate a Bootstrap 4 default breadcrumb into your web projects. This UI component provides a simple and effective way to display the navigation path of your website, enhancing user experience. Follow these straightforward steps to seamlessly incorporate this feature into your own project:
Copy the Code Snippet:
- Begin by copying the provided HTML code snippet for the Bootstrap 4 default breadcrumb.
Link Bootstrap CSS:
- Ensure Bootstrap CSS is linked in the <head> section of your HTML file. Include the following link:
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
Customize and Make It Yours:
- Modify the breadcrumb component to fit your specific navigation path and design requirements. Adjust the breadcrumb items, links, and styling to match your website's structure and theme. You can use additional Bootstrap utility classes or custom CSS to further customize the appearance.
Test and Implement:
- Test the appearance and functionality of the breadcrumb to ensure it behaves as expected. Verify that the breadcrumb is responsive and displays correctly across different devices and screen sizes.
By following these steps, you can effectively integrate and customize the Bootstrap 4 default breadcrumb according to your project's needs. Enhance user navigation and experience with this clear and responsive UI component.
Code Explanation
Navigation Element (<nav class="container mt-5" aria-label="breadcrumb">
):
<nav>
is an HTML element used to define a set of navigation links.- class="container mt-5":
- container is a Bootstrap class that provides a responsive fixed-width container.
- mt-5 adds margin (m) on the top (t) with size 5 (large), creating vertical spacing above the container.
- aria-label="breadcrumb":
- The aria-label attribute provides an accessible name for the navigation region, making it clear that this is a breadcrumb navigation.
Ordered List (<ol class="breadcrumb">
):
<ol>
is an HTML element that defines an ordered list.- class="breadcrumb" is a Bootstrap class that styles the list as a breadcrumb navigation.
Breadcrumb Items:
- Home Item (
<li class="breadcrumb-item">
<a href="#">
Home</a>
</li>
):<li>
is an HTML element that defines a list item.- class="breadcrumb-item" is a Bootstrap class that styles the list item as part of a breadcrumb.
<a href="#">
Home</a>
creates a hyperlink with the text "Home".
- Library Item (
<li class="breadcrumb-item">
<a href="#">
Library</a>
</li>
):- Similar to the "Home" item, this is another breadcrumb item with a hyperlink to "Library".
- Active Item (
<li class="breadcrumb-item active" aria-current="page">
Data</li>
):- class="breadcrumb-item active":
- breadcrumb-item styles the item as part of the breadcrumb.
- active indicates that this is the current page.
- aria-current="page" provides screen readers with information that this item represents the current page in the navigation hierarchy.
- "Data" is the text displayed for this breadcrumb item, indicating it is the current page.