CSS scrollbar color: why it works in Chrome but not Firefox

PublishedToolCSS Scrollbar Styler

Contents
  1. When your code works in one browser but not the other
  2. Why Chrome and Firefox use separate syntax
  3. Common mistakes
  4. The takeaway
  5. Frequently Asked Questions

If you searched for scrollbar color CSS, pasted it in, and nothing on screen changed, it's usually because you added only the Chrome syntax or only the Firefox syntax. The two browsers handle scrollbars with different syntax. Without knowing that, you can swap the code in several times and still struggle to find the cause. This post lays out the verifiable facts behind why the two syntaxes exist separately, plus another common reason your code still doesn't apply.

Summary ① Chrome, Safari, and Edge use the ::-webkit-scrollbar family of pseudo-elements, while Firefox uses the standard scrollbar-color and scrollbar-width properties. These are completely different syntaxes. ② scrollbar-width can't set an exact px value. You can only choose from thin, auto, and none. ③ CSS must be set on the class of the element that actually has overflow and scrolls, not on body.

When your code works in one browser but not the other

This is common when you're trying to add a brand-colored scrollbar to an area with overflow-y: auto, like a side menu or card list. You paste CSS you found in a search, and the color changes in Chrome. Open the same page in Firefox, and you still see the default gray scrollbar.

The reverse happens too. Code from another post works in Firefox but does nothing in Chrome. The code isn't wrong. It just includes syntax for only one browser engine.

Why Chrome and Firefox use separate syntax

Styling scrollbars with CSS falls into two camps depending on the browser engine. One is the ::-webkit-scrollbar pseudo-element used by WebKit and Blink browsers such as Chrome, Safari, and Edge. The other is the CSS Scrollbars standard, implemented by Firefox as the scrollbar-color and scrollbar-width properties.

::-webkit-scrollbar, used by Chrome, Safari, and Edge

The ::-webkit-scrollbar family is not a W3C standard. It's a non-standard extension that WebKit introduced first. Each part of the scrollbar gets its own pseudo-element.

.custom-scrollbar::-webkit-scrollbar {
  width: 10px;
}
.custom-scrollbar::-webkit-scrollbar-track {
  background: #f1f5f9;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
  background: #6366f1;
  border-radius: 5px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: #6366f1cc;
}

The color in -thumb:hover is the thumb color with two hexadecimal digits, cc, added to the end. cc is 204 in decimal, and 204 divided by 255 is about 0.8, or about 80% opacity. It's the original color with transparency added, not a new color.

scrollbar-color and scrollbar-width, used by Firefox

Firefox, by contrast, needs just two standard properties.

.custom-scrollbar {
  scrollbar-color: #6366f1 #f1f5f9;
  scrollbar-width: thin;
}

scrollbar-color takes two values: the first is the thumb color and the second is the track (background) color. If you swap the order, the colors flip.

The CSS Scrollbars standard defines only three values for scrollbar-width: auto, thin, and none. The standard itself has no value for setting thickness in pixels. So there's no way to reproduce an exact width like 10px in Firefox. You can only approximate it: use thin if it's thinner than the baseline, and auto for anything larger.

Recent versions of Chromium-based browsers have started to recognize scrollbar-color as well, but for a long time this property was Firefox-only. That's why, even now, including both syntaxes is the way to cover all browsers.

Still no change after combining both? It's probably your selector

If the scrollbar still doesn't change after you add both blocks, the cause is usually the selector. The code above is written to apply only to an element with the class .custom-scrollbar. You need to put that class on the element that actually scrolls, the one with overflow: auto or overflow: scroll.

If you want to change the page-wide scrollbar, put the class on body or html. If scrolling happens only inside a specific area, such as a card list, put it on the element that wraps that area. If you set it on body but the actual scrolling happens in an inner div, the body scrollbar may change while the scrollbar you actually see on screen stays the same.

Check it with our free tool.

CSS Scrollbar Styler

Adjust color, width, and roundness to generate both the Chrome and Firefox CSS at once. Everything is calculated in your browser and never sent to a server.

Common mistakes

ItemChrome, Safari, and Edge (WebKit syntax)Firefox (standard properties)
Styling method::-webkit-scrollbar pseudo-elementsscrollbar-color, scrollbar-width
Width controlSet an exact px valueChoose only thin, auto, or none
Hover colorSet separately with the :hover pseudo-classNo separate syntax; the browser handles it
Standard?Non-standard (vendor extension)CSS Scrollbars standard

The most common mistake is adding only one syntax and ignoring the other browsers. If you add only ::-webkit-scrollbar, nothing happens in Firefox. If you add only scrollbar-color, browsers that don't recognize it keep the default scrollbar.

The second is misunderstanding width. You set 10px in Chrome and expect 10px in Firefox, but it won't match. Firefox responds only at two levels, thin or auto, so the scrollbar widths in the two browsers won't match down to the pixel.

The third is hover color. In Chrome, you can set a separate thumb color with the :hover pseudo-class. Firefox's scrollbar-color has no standard syntax for the hover state. If the color shifts slightly on hover, that's the browser handling it on its own, not a value you set in CSS.

The takeaway

  • Chrome, Safari, and Edge use the ::-webkit-scrollbar family of pseudo-elements. Firefox uses the standard scrollbar-color and scrollbar-width properties. Add only one, and the other browsers keep the default scrollbar.
  • scrollbar-width can't take a pixel value. You can only choose thin, auto, or none.
  • Set the CSS on the class of the element where scrolling actually happens (the element with overflow). If you put it on body but another element is the one that scrolls, it won't apply.
  • In Chrome, you can set the mouse hover color directly with :hover. Firefox has no such syntax.
CSS Scrollbar Styler

Adjust color, width, and roundness to generate both the Chrome and Firefox CSS at once. Everything is calculated in your browser and never sent to a server.

Frequently Asked Questions

Can I set the scrollbar thickness to an exact value like 15px?

In Chrome, Safari, and Edge, you can set the exact pixel value you want using the width value of ::-webkit-scrollbar. But Firefox's scrollbar-width only allows three standard values: auto, thin, and none. So you can't set an exact value like 15px — you can only approximate it with whichever is closer, thin or auto.

I added the code and it only works in Chrome. In Firefox nothing changes. Why?

Most likely you added only the ::-webkit-scrollbar syntax without including scrollbar-color and scrollbar-width. The two syntaxes don't replace each other, so to apply to both browsers you need to include both blocks together.

Where do I paste the generated CSS?

Change the class name in the code (like .custom-scrollbar) to the class name of the element that actually scrolls — that is, the element with overflow: auto or overflow: scroll — and apply it to that element. If you want the whole page scrollbar, apply it to body or html. If the scrolling happens inside a specific area, apply it to that area's element for it to take effect.

Does this CSS work in Safari too?

Safari uses the WebKit engine, so ::-webkit-scrollbar pseudo-elements apply the same way as in Chrome. Firefox's standard properties, scrollbar-color and scrollbar-width, may or may not be recognized depending on the browser version, so it's safer to include both syntaxes.

This article was adapted from our Korean original. Read the Korean original

Related articles

  1. Share Secret Text Without Storing It on a ServerHow to compress and encrypt text in your browser and share it in a URL hash, with no server storage — plus why password lock is what actually encrypts it.
  2. Uppercase/Lowercase Converter: Sentence, Title, Snake & Kebab CaseLearn the rules behind Sentence Case, Title Case, snake_case, and kebab-case, plus the options you can use in our converter to fix English text fast.
  3. URL Slug Generator Rules: Lowercase, Hyphens, Clean SlugsSee the exact rules and regex that turn a title into a clean lowercase hyphen slug, and compare results with and without Korean characters kept.
  4. Smart Quotes Cleaner: Convert Curly Quotes to ASCIIWord and messenger editors turn straight quotes into curly ones, which breaks code. Here's why it happens and how to convert them back to plain ASCII.
  5. Browser Mic Dictation: Why It Works in Chrome but Not FirefoxUse the Web Speech API to dictate mic audio into text in your browser with no install, see which browsers support it, and learn why Firefox can't.
  6. Split Text Into Sentences: Punctuation Rules and Line BreaksHow sentence splitting works: split on . ? ! and …, skip decimals and common abbreviations like Dr. and e.g., and format the output as lines or lists.

Related tools