Click here to Skip to main content
Click here to Skip to main content

Manipulating scrollbar colors using CSS and JavaScript

, 4 Sep 2001
Rate this:
Please Sign up or sign in to vote.
The thing about the default color of scrollbars is that they are dull and ugly. Wouldn't it be nice to change this color to better fit the overall theme of your site? See how to use Cascading Style sheets and JavaScript to do just that!


The thing about the default color of scrollbars is that it's dull and ugly. Usually this color is gray. Wouldn't it be nice to change this color to better fit the overall theme of your site? Luckily Cascading Style sheets and JavaScript can be used to do just that!

Using CSS

In CSS, you would just add this code to the top of your page to customize the browser's scrollbar colors: The great thing about CSS is that browsers that don't understand it will just skip it, in this case, Netscape browsers.


Play around with the different values!

Using JavaScript

I can use JavaScript to dynamically change the scrollbar color. This is useful when I wish to do something more fancy, like alternating the scrollbar from one color to another. The code required is:"colorname""colorname""colorname""colorname""colorname""colorname""colorname"

A very good demonstration of this is a script written by Svetlin Staev, which changes the scrollbar colors when you move your mouse over and out of it:

I'm seeing more and more sites customize the scrollbar color to blend in with the rest of their sites. Hope you find this tutorial useful in helping you do the same!


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Ada Shimar

United States United States
No Biography provided

Comments and Discussions

QuestionThe scollbar references listed in CSS and Javascript are not found. PinmemberASPCoder77712-Jul-11 8:13 
Questionis it working only for documents scroll bar ?? can i use for Panel scrollbar ?? PinmemberNirav Pate !22-Aug-08 20:21 
GeneralGood job! Pinmemberjoelperez7-Aug-08 10:27 
GeneralAbout Dreamweaver PinsussAnonymous14-May-05 1:47 
Generalin mozilla don&#180;t work PinsussAnonymous12-Mar-05 11:25 
Generalhide horizontal scrollbar PinsussRayran6-May-04 8:12 
GeneralRe: hide horizontal scrollbar PinsussAnonymous25-May-04 10:41 
Questiontutotial? PinmemberMark Focas31-Aug-03 13:47 
AnswerRe: tutotial? PinmemberMember 43056771-Aug-08 2:09 
GeneralScrollbar width PinsussOnyxMax20-Jul-02 20:11 
GeneralRe: Scrollbar width PinsussAnonymous3-Dec-02 2:57 
GeneralCool ,Thanks... PinmemberJosh Knox20-Dec-01 20:03 
GeneralRequirements PinmemberPhilippe Lhoste11-Sep-01 5:49 
GeneralRe: Requirements PinmemberHockey19-Apr-02 12:51 
QuestionWhy? PinmemberRay Hayes5-Sep-01 2:14 
AnswerRe: Why? PinmemberAda Shimar5-Sep-01 9:51 
AnswerRe: Why? PinmemberPaul Watson11-Feb-02 21:16 
AnswerRe: Why? PinmemberDuc Truong21-Aug-02 14:43 
GeneralRe: Why? PinsussAnonymous16-Jun-04 2:53 
AnswerRe: Why? PinsussAnonymous20-Oct-02 8:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141223.1 | Last Updated 5 Sep 2001
Article Copyright 2001 by Ada Shimar
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid