How to create a Breadcrumb Navigation ?
Last Updated :
05 Jun, 2023
In this article, we will learn how to create breadcrumbs navigation. Breadcrumb navigation is a website navigation scheme that visually represents the user's path from the homepage to the current page. It typically appears as a horizontal trail of links, showing the hierarchical structure of pages. Breadcrumbs aid in easy navigation and provide context for users within a website.
Approach 1: We will follow the below steps for creating breadcrumbs using only CSS. This method allows you to exactly customize how the breadcrumbs would look like.
Step 1: Create an HTML list of the navigation links.
<ul class="breadcrumb-navigation">
<li><a href="home">Home</a></li>
<li><a href="webdev">Web Development</a></li>
<li><a href="frontenddev">Frontend Development</a></li>
<li>JavaScript</li>
</ul>
Step 2: Set the CSS display: inline in order to show the list in the same line.
.breadcrumb-navigation > li {
display: inline;
}
Step 3: Add a separator after every list element.
.breadcrumb-navigation li + li:before {
padding: 4px;
content: "/";
}
Example: In this example, we will use the above-explained approach.
HTML
<!DOCTYPE html>
<html>
<head>
<style>
.breadcrumb-navigation {
padding: 10px 18px;
background-color: rgb(238, 238, 238);
}
.breadcrumb-navigation>li {
display: inline;
}
.breadcrumb-navigation>li>a {
color: #026ece;
text-decoration: none;
}
.breadcrumb-navigation>li>a:hover {
color: #6fc302;
text-decoration: underline;
}
.breadcrumb-navigation li+li:before {
padding: 4px;
content: "/";
}
</style>
</head>
<body>
<h1 style="color: green">GeeksforGeeks</h1>
<ul class="breadcrumb-navigation">
<li>
<a href="home">
Home
</a>
</li>
<li>
<a href="webdev">
Web Development
</a>
</li>
<li>
<a href="frontenddev">
Frontend Development
</a>
</li>
<li>JavaScript</li>
</ul>
</body>
</html>
Output:

Approach 2: We will follow the below steps for creating breadcrumbs using the Bootstrap library. This allows one to quickly create good-looking breadcrumbs.
Step 1: We simply add aria-label="breadcrumb" to the nav element.
<nav aria-label="breadcrumb">
Step 2: We next add class="breadcrumb-item" in the list elements.
<li class="breadcrumb-item"><a href="#">
Home
</a></li>
Step 3: Add class="breadcrumb-item active" in the current list element.
<li class="breadcrumb-item active" aria-current="page">
JavaScript
</li>
Example: In this example, we are using the above approach.
HTML
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href=
"https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" />
</head>
<body>
<h1 style="color: green">
GeeksforGeeks
</h1>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="home">
Home
</a>
</li>
<li class="breadcrumb-item">
<a href="webdev">
Web Development
</a>
</li>
<li class="breadcrumb-item">
<a href="frontenddev">
Frontend Development
</a>
</li>
<li class="breadcrumb-item active"
aria-current="page">
JavaScript
</li>
</ol>
</nav>
</body>
</html>
Output:

Similar Reads
Chakra UI Navigation Breadcrumb Chakra UI Navigation Breadcrumb is a versatile and user-friendly component designed for efficient navigation within web applications. With a focus on simplicity and customization, Chakra UI Breadcrumb seamlessly integrates into Chakra UI, a popular React component library. It enables developers to c
2 min read
Breadcrumb Navigation in Design Breadcrumb navigation is an essential element of the User Interface design and implementation, which in particular on websites and in applications with hierarchical structures. The title of the work is inspired by the fairy tale "Hansel and Gretel," during which the youngsters dropped the bread trai
5 min read
React MUI Breadcrumbs Navigation MUI or Material-UI, itâs a React component library. It enables you to build your own design system and develop React applications faster. It is basically a design language that was developed by Google in 2014. It uses more Design and Animation, grid-system, and provides shadows and lightning effects
3 min read
How to create a Pills navigation menu in Bootstrap? In this article, we will learn how to make a Pills navigation menu in Bootstrap 5. Pills are a great navigation style to implement for your websites as it enhances the user experience and navigation flow of your website. Creating a pills navigation menu is simple and easy, all you have to do is to i
7 min read
How to Create Intuitive Navigation? The intuitive navigation serves as the nucleus of user experience design in the digital arena shaping the userâs interaction with and the presentation pathways of websites, applications, and software interfaces. It's the designer's art and the science of developing navigational systems that are easy
6 min read