Creating Breadcrumbs Navigation
To create breadcrumbs navigation in HTML, use a list (ul) within a nav element and style it horizontally with CSS.
Breadcrumbs help the user understand their current position within a site's hierarchy. They can be very useful for complex sites, as they provide an easy way for the user to jump back to a higher-level page.
The Basic HTML Structure
Each "crumb" in your breadcrumb trail should be a link within a list item:
Notice the aria-label="Breadcrumb" attribute on the nav element. This tells screen readers exactly what kind of navigation this is, making it accessible to screen reader users.
Styling and Separators
To make the list horizontal, set the display property to flex or inline-block. You can then use the ::before or ::after pseudo-element to add a separator character, like a slash (/) or an arrow (>), between each item.
Full Working Example
In the following example, the breadcrumbs are styled horizontally and include separators:
The Last Item
The last item in the list should usually not be a link, as it represents the current page. You can style it differently (e.g., with a different color) to distinguish it from the clickable links in the trail. You can also add aria-current="page" to this item to help accessibility further.