Breadcrumb navigation helps the user to understand their location in the website by providing a breadcrumb trail back to the start page.
[[File:../../../../../../media.prod.mdn.mozit.cloud/attachments/2018/10/07/16228/ac938167cac88750efe6f1ba3e30e328/breadcrumb-navigation.png|Links displayed inline with separators]]
Requirements
The items typically display inline with a separator to indicate a hierarchy between individual pages.
Recipe
Note: The example above uses two selectors to insert content before every li
except the first one. This could also be achieved using one selector only:
.breadcrumb li:not(:first-child)::before { content: "→"; }
This solution uses a more complex selector, but requires less rules. Feel free to choose the solution that you prefer.
Choices made
This pattern is laid out using a simple flex layout demonstrating how a line of CSS can give us our navigation. The separators are added using CSS Generated Content. You could change these to any separator that you like.
Accessibility concerns
I have used the aria-label
and aria-current
attributes to help users understand what this navigation is and where the current page is in the structure. See the related links for more information.
Browser compatibility
The various layout methods have different browser support. See the charts below for details on basic support for the properties used.
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Flexbox
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
flex
|
Chrome Full support 29 Full support 29 Full support 21 Prefixed' Implemented with the vendor prefix: -webkit- |
Edge Full support 12 Full support 12 Full support 12 Prefixed' Implemented with the vendor prefix: -webkit- |
Firefox Full support 20 Full support 20 Notes' Since Firefox 28, multi-line flexbox is supported.
Notes' Before Firefox 32, Firefox wasn't able to animate values starting or stopping at Disabled' From version 18 until version 28 (exclusive): this feature is behind the Prefixed' Implemented with the vendor prefix: -webkit- Full support 48 Prefixed' Implemented with the vendor prefix: -webkit-
Disabled' From version 48: this feature is behind the |
IE Full support 11 Full support 11 Notes' Internet Explorer 11 ignores uses of Prefixed' Implemented with the vendor prefix: -ms-
Notes' Internet Explorer 10 and 11 ignore uses of |
Opera
Full support 12.1 |
Safari Full support 9 Full support 9 Full support 6.1 Prefixed' Implemented with the vendor prefix: -webkit- |
WebView Android Full support 4.4 Full support 4.4 Full support ≤37 Prefixed' Implemented with the vendor prefix: -webkit- |
Chrome Android Full support 29 Full support 29 Full support 25 Prefixed' Implemented with the vendor prefix: -webkit- |
Firefox Android Full support 20 Full support 20 Notes' Since Firefox 28, multi-line flexbox is supported.
Notes' Before Firefox 32, Firefox wasn't able to animate values starting or stopping at Disabled' From version 18 until version 28 (exclusive): this feature is behind the Prefixed' Implemented with the vendor prefix: -webkit- Full support 48 Prefixed' Implemented with the vendor prefix: -webkit-
Disabled' From version 48: this feature is behind the |
Opera Android
Full support 12.1 |
Safari iOS Full support 9 Full support 9 Full support 7 Prefixed' Implemented with the vendor prefix: -webkit- |
Samsung Internet Android Full support 2.0 Full support 2.0 Full support 1.5 Prefixed' Implemented with the vendor prefix: -webkit- |
Legend
- Full support
- Full support
- See implementation notes.'
- See implementation notes.
- User must explicitly enable this feature.'
- User must explicitly enable this feature.
- Requires a vendor prefix or different name for use.'
- Requires a vendor prefix or different name for use.
See also
Breadcrumb Navigation by Mozilla Contributors is licensed under CC-BY-SA 2.5.