Ask any question about CSS here... and get an instant response.
Post this Question & Answer:
How can I create a custom scrollbar style using pure CSS? Pending Review
Asked on Apr 13, 2026
Answer
To create a custom scrollbar style using pure CSS, you can use the `::-webkit-scrollbar` pseudo-elements for WebKit browsers like Chrome and Safari. This allows you to style the scrollbar's track, thumb, and other components.
<!-- BEGIN COPY / PASTE -->
<style>
/* Style the scrollbar track */
::-webkit-scrollbar {
width: 12px;
}
/* Style the scrollbar thumb */
::-webkit-scrollbar-thumb {
background-color: #888;
border-radius: 6px;
}
/* Style the scrollbar thumb on hover */
::-webkit-scrollbar-thumb:hover {
background-color: #555;
}
/* Style the scrollbar track */
::-webkit-scrollbar-track {
background-color: #f1f1f1;
}
</style>
<!-- END COPY / PASTE -->Additional Comment:
- The `::-webkit-scrollbar` pseudo-element targets the entire scrollbar.
- The `::-webkit-scrollbar-thumb` styles the draggable part of the scrollbar.
- The `::-webkit-scrollbar-track` styles the track where the thumb slides.
- These styles are specific to WebKit-based browsers; other browsers may not support these properties.
- Consider using JavaScript or a library for cross-browser compatibility if needed.
Recommended Links:
