CSS Scrollbar Styling: scrollbar-color vs ::-webkit-scrollbar
Scrollbar styling without -webkit- pseudo-elements
Styling scrollbars required ::-webkit-scrollbar, ::-webkit-scrollbar-track, and ::-webkit-scrollbar-thumb. Non-standard WebKit-only pseudo-elements that Firefox never supported. scrollbar-color and scrollbar-width are the standard two-property replacement.
The old hack vs the modern fix
View demo/* Chrome + Safari only — Firefox ignores all of this */
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-track {
background: #f1f1f1;
}
::-webkit-scrollbar-thumb {
background: #888;
}
::-webkit-scrollbar-thumb:hover {
background: #555;
}* {
scrollbar-width: thin;
scrollbar-color: #888 transparent;
}Scrollbar color browser support
Live demo
Why the modern way wins
Works in Firefox
::-webkit-scrollbar never worked in Firefox. scrollbar-color and scrollbar-width are supported in Chrome, Firefox, Safari, and Edge.
Two properties instead of six
scrollbar-color takes two values: thumb color and track color. scrollbar-width is thin, auto, or none. No pseudo-elements needed.
Use CSS custom properties
Both properties accept any CSS color value, including custom properties. Scrollbar colors can follow your theme variables.
- Lines Saved
- 6 → 4
- No webkit pseudo-elements
- Old Approach
- ::-webkit-scrollbar
- Chrome and Safari only, 3+ pseudo-elements
- Modern Approach
- scrollbar-color
- Standard CSS, two properties
How it works
The ::-webkit-scrollbar family of pseudo-elements let Chrome and Safari style scrollbars, but they were never part of the CSS standard and Firefox never implemented them. Styling scrollbars cross-browser required either a polyfill or accepting that Firefox users would see the default system scrollbar.
scrollbar-color takes two color values: the thumb and the track. scrollbar-width accepts auto, thin, or none. scrollbar-color is inherited, but scrollbar-width is not. Set the width on each scroller, or use * as shown to cover every scrollbar on the page. Safari added support in version 26.2.
Want to try colors and widths first? The scrollbar styler shows the result on a live scroll box and gives you the CSS to copy.