Targeting only Firefox with CSS

OK, I’ve found it. This is probably the cleanest and easiest solution out there and does not rely on JavaScript being turned on.

@-moz-document url-prefix() {
  h1 {
    color: red;
  }
}
<h1>This should be red in FF</h1>

It’s based on yet another Mozilla specific CSS extension. There’s a whole list for these CSS extensions right here: Mozilla CSS Extensions.

Leave a Comment