How to Add a User Stylesheet in Firefox

By  on  

While many like to complain about CSS these days, it's important to remember how amazing CSS is; the CSS language is:

  • easy to learn
  • easy to read
  • easy to write
  • simple to understand

Web developers and designers alike love that CSS allows us to take text/media and present it in a beautiful, logical fashion. While we love that we control our own sites, it's obvious that we don't always agree with other web developers' decisions, and would prefer to modify designs for the purposes of simple UI improvement or hiding ads, etc.

The amazing Firefox web browser allows users to create and include a user stylesheet into each page to allow the user to modify ever single web page as necessary. Let me show you how to do it!

Step 1: Locate and Open Profile Directory

The user stylesheet will be added to your each user profile, not the browser code itself; this makes sense since each profile may want a different UI modifications. In the address bar, visit about:support and click Profile Folder's "Show in Finder" (or likewise) button:

about:support Firefox

The directory will be opened on your system in Finder (Mac) or Explorer (Windows).

Step 2: Create chrome Directory

Create a chrome directory within the designated profile directory which will host the necessary userContent.css file:

Firefox profile chrome

Having the userContent.css file in this directory will allow the user stylesheet to not be lost during Firefox upgrades.

Step 3: Create userContent.css

Firefox adds the userContent.css file on every page, if it exists, so add userContent.css within the chrome directory. This file should host all modifications to any page you visit, so don't create overly broad CSS selectors which will apply to every website.

Firefox stylesheet
/* an overly aggressive style just to prove it works */
body {
  background: pink !important;
}

Firefox stylesheet

There's no way to isolate a user style by domain so be as specific as possible so you don't unknowingly break other websites.

Step 4: Restart Firefox

User styles aren't applied to sites until you restart Firefox. Once Firefox has been restarted, the styles in your userContent.css will be applied to the page.

Bonus: userChrome.css

While the userContent.css allows the user to set CSS for all page content, you can also create a userChrome.css file which is applied to the browser chrome.

The ability to easily create a user stylesheet to customize any webpage is another reason to love Firefox!

Recent Features

  • By
    7 Essential JavaScript Functions

    I remember the early days of JavaScript where you needed a simple function for just about everything because the browser vendors implemented features differently, and not just edge features, basic features, like addEventListener and attachEvent.  Times have changed but there are still a few functions each developer should...

  • By
    5 Awesome New Mozilla Technologies You’ve Never Heard Of

    My trip to Mozilla Summit 2013 was incredible.  I've spent so much time focusing on my project that I had lost sight of all of the great work Mozillians were putting out.  MozSummit provided the perfect reminder of how brilliant my colleagues are and how much...

Incredible Demos

  • By
    Create Spinning Rays with CSS3 Animations & JavaScript

    Thomas Fuchs, creator of script2 (scriptaculous' second iteration) and Zepto.js (mobile JavaScript framework), creates outstanding animated elements with JavaScript.  He's a legend in his own right, and for good reason:  his work has helped to inspire developers everywhere to drop Flash and opt...

  • By
    WebKit-Specific Style:  -webkit-appearance

    I was recently scoping out the horrid source code of the Google homepage when I noticed the "Google Search" and "I'm Feeling Lucky" buttons had a style definition I hadn't seen before:  -webkit-appearance.  The value assigned to the style was "push-button."  They are buttons so that...

Discussion

  1. randomWebDev

    I dont understand the purpose behind this. Why would a user write his own Stylesheet for a Website? To “hide ads”?? Sure, there will be many people who open the debugger, analyse which div holds the ad and write a stylesheet to hide it… not? Adblocker?? Unless you are visting a Website every day and are REALLY displeased with the looks, I just cannot imagine that there is anyone who would bother to do this.

    • H

      Lots of people do this because for some, the colors are either bothersome (white may hurt your eyes, or a dark background may be too low contrast to see it clearly). Or if you have low vision, certain types of colorblindness, you might need to add your own colors so you can see the page.

    • MMIAngou

      It’s not because you don’t need it that it is useless ; this is a huge feature for accessibility, so :
      – Old person may want the font 200% bigger
      – Custom fonts easier to read for Dislexia
      – Custom colors for colorblind

      And this can apply on all the sites you will visit

  2. David S.

    I once thought user styles couldn’t be limited to a specific domain as well, but then I found this: https://developer.mozilla.org/en-US/docs/Web/CSS/@document

    I’d like to add that there are multiple extensions for Chromium-based browsers (Google Chrome, Opera, etc.) to add user stylesheets in them as well (including Stylus, Stylish, and Stylebot).

  3. MMIAngou

    Someone knows the name of this particular Firefox theme ?

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!