Scrollbar Styling with ::-webkit-scrollbar
Customize scrollbar appearance using webkit pseudo-elements and the scrollbar-color property.
Scrollbar Styling with ::-webkit-scrollbar is a free CSS Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the CSS Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Scrollbar Styling Overview
Browsers render default scrollbars that differ across operating systems. CSS allows customizing scrollbar appearance using non-standard webkit pseudo-elements and the modern standard properties.
::-webkit-scrollbar
The root pseudo-element for the entire scrollbar. Set width (vertical) and height (horizontal):
::-webkit-scrollbar {
width: 8px; /* vertical scrollbar width */
height: 8px; /* horizontal scrollbar height */
}::-webkit-scrollbar-track
The track is the background channel the thumb slides along:
::-webkit-scrollbar-track {
background: #f0f0f0;
border-radius: 4px;
}::-webkit-scrollbar-thumb
The thumb is the draggable scroll indicator:
::-webkit-scrollbar-thumb {
background: #c0c0c0;
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: #999;
}Custom Scrollbar Complete
A complete custom scrollbar implementation:
/* Applies to all scrollable elements */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
background: rgba(0,0,0,0.2);
border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
background: rgba(0,0,0,0.4);
}Modern Standard: scrollbar-color
scrollbar-color is the standardized property supported by Firefox. It sets thumb and track colors in one declaration:
body {
scrollbar-color: #c0c0c0 #f0f0f0;
/* thumb track */
}Modern Standard: scrollbar-width
scrollbar-width controls scrollbar size with keyword values:
body {
scrollbar-width: thin; /* thinner scrollbar */
/* or: none (hidden), auto (default) */
}Cross-Browser Scrollbar Styling
For full cross-browser coverage, use both approaches:
/* Modern standard (Firefox, Chrome 121+) */
body {
scrollbar-color: #c0c0c0 #f0f0f0;
scrollbar-width: thin;
}
/* Webkit (Chrome, Safari, Edge) */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: #c0c0c0; }
::-webkit-scrollbar-track { background: #f0f0f0; }Hiding Scrollbars While Keeping Scroll
Make an element scrollable but hide the scrollbar visually:
.hide-scrollbar {
overflow: auto;
scrollbar-width: none; /* Firefox */
-ms-overflow-style: none; /* IE 10+ */
}
.hide-scrollbar::-webkit-scrollbar {
display: none; /* WebKit */
}Dark Mode Scrollbars
Use the CSS color-scheme property to get OS-native dark scrollbars without custom styling:
html {
color-scheme: dark light; /* browser picks appropriate scrollbar */
}Accessibility Reminder
Do not make scrollbars too small or invisible in a way that makes scrolling hard to discover. Hidden scrollbars are acceptable for touch-first designs but can be confusing on desktop.
Quick Check
Which standardized CSS property sets scrollbar colors and is supported in Firefox?
Recap
Customize scrollbars with ::-webkit-scrollbar pseudo-elements (WebKit) and the standard scrollbar-color/scrollbar-width properties (Firefox/modern browsers). Use both for full cross-browser support. Use scrollbar-width: none + the webkit equivalent to hide scrollbars while preserving scroll functionality.
Frequently asked questions
Is the “Scrollbar Styling with ::-webkit-scrollbar” lesson free?
Yes — the full text of “Scrollbar Styling with ::-webkit-scrollbar” is free to read here on the web, and the CSS Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the CSS Academy course, upgrade to CoddyKit PRO.
What will I learn in “Scrollbar Styling with ::-webkit-scrollbar”?
Customize scrollbar appearance using webkit pseudo-elements and the scrollbar-color property. You practise CSS Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start CSS Academy?
No prior experience is required. CSS Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Scrollbar Styling with ::-webkit-scrollbar” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this CSS Academy lesson?
Yes. Every CSS Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- overflow: hidden scroll auto clip
- scroll-behavior: smooth
- scroll-snap-type and scroll-snap-align
- Scrollbar Styling with ::-webkit-scrollbar