Creating colored scrollbars
If you have been creating websites for yourself or others, you always try to find and think of creative ways to enhance your page visually. One such way is to create a colored scrollbar through
Here's how it works
We use our body as a selector and add the following
body{
scrollbar-face-color: #cc9900;
scrollbar-shadow-color:#000000;
scrollbar-highlight-color: #000000;
scrollbar-3dlight-color: #000000;
scrollbar-darkshadow-color:#000000;
scrollbar-3dtrack-color: #666666;
scrollbar-arrow-color: #000000;
}
The
Embedded or External?
You may declare this either way. If you want to color your scrollbar for multiple pages; then use external, otherwise, if it’s for one page, use embedded.
Disadvantages to using colored scrollbars
This method is not supported by the following browsers:
- Netscape
- Mozilla
- Opera
This is not supported by Internet Explorer 6 if you use a full DOCTYPE. DOCTYPE stands for Document which is short for Document Type Declaration. A DOCTYPE is a way to ensure all markup tags are correctly created, formed, nested and closed, as well as using correct
You might be wondering how the finished file works if Internet Explorer 6 does not support colored scrollbar using a full DOCTYPE. There are two options which are discussed below:
1). Replace the body selector with
2) A cleaner approach if you need or are concerned with validation is conditional comments. Conditional comments are a function built into Internet Explorer and are only visible in Internet Explorer. Thus, we can wrap our html selector inside a conditional comment and it will pass validation. However, if you need validation, you’ll have to embed these workaround, since conditional comments don’t work in external style sheets.
We simply add the following code inside the opening and closing head tags:
<head>
<!--[if IE]>
<style type="text/css">
html{scrollbar-face-color: #cc9900;
scrollbar-shadow-color:#000000;
scrollbar-highlight-color: #000000;
scrollbar-3dlight-color: #000000;
scrollbar-darkshadow-color:#000000;
scrollbar-3dtrack-color: #666666;
scrollbar-arrow-color: #000000;}
</style>
<![endif]-->
</head>
If you have questions, contact me.