Home > CSS, HTML > Using DOCTYPE and Changing Style of Scrollbar with CSS

Using DOCTYPE and Changing Style of Scrollbar with CSS

If you used DOCTYPE in your pages, you may be in trouble with changing scrollbar color and style. Web developers usually define scrollbar properties in body tag in CSS. However, if you used DOCTYPE this is not going to work. All you need to do, defining scrollbar style in HTML tag in CSS file, and… Yes, that’s all!


Wrong Usage: Style.css

1
2
3
4
5
6
7
8
9
10
11
12
13
14
body{
/*
Your other body style properties…

*/

scrollbar-base-color: #C1CBD7;
scrollbar-arrow-color: #9DACBF;
scrollbar-3dlight-color: #C1CBD7;
scrollbar-darkshadow-color: #C1CBD7;
scrollbar-face-color: #C1CBD7;
scrollbar-highlight-color: #C1CBD7;
scrollbar-shadow-color: #C1CBD7;
scrollbar-track-color: #FFFFFF;
}


Correct Usage: Style.css

1
2
3
4
5
6
7
8
9
10
html{
scrollbar-base-color: #C1CBD7;
scrollbar-arrow-color: #9DACBF;
scrollbar-3dlight-color: #C1CBD7;
scrollbar-darkshadow-color: #C1CBD7;
scrollbar-face-color: #C1CBD7;
scrollbar-highlight-color: #C1CBD7;
scrollbar-shadow-color: #C1CBD7;
scrollbar-track-color: #FFFFFF;
}


As you see, for coloring the scrollbar in DOCTYPE used web sites, we are writing scrollbar properties in html tag. On the other hand, some browsers may not support coloring the scrollbar. For instance, this usage is working on Internet Explorer but not on Firefox.

Bookmark and Share
Categories: CSS, HTML Tags: , , , , , ,
  1. serdar
    December 4th, 2009 at 01:16 | #1

    yeah it is easy to set the style of scrollbars using css, but how can u change scrollbar style using javascript without any page refreshes if there is a doctype?i can do it when there is no doctype defined but having a problem wit a doctype on the page.

  2. December 5th, 2009 at 18:32 | #2

    I made a quick research but unfortunatelly, there is no way to change scrollbar colors with javascript using doctype. Because we need to change sytle of html element but i couldn’t find any method to change html element properties with javascript. I mean, we use this in IE

    document.body.style.scrollbarBaseColor = ‘#FF0000′;

    if we could use
    document.html.style.scrollbarBaseColor = ‘#FF0000′;

    or something like that we could change the scrollbar color too..

    I will make a research about it soon. But i’m not hopeful. If you can find a way, please share with us. Good luck.

  1. No trackbacks yet.
eXTReMe Tracker