Join the AMA (Ask Me Anything) with the Firefox leadership team to celebrate Firefox 20th anniversary and discuss Firefox’s future on Mozilla Connect. Mark your calendar on Thursday, November 14, 18:00 - 20:00 UTC!

This site will have limited functionality while we undergo maintenance to improve your experience. If an article doesn't solve your issue and you want to ask a question, we have our support community waiting to help you at @FirefoxSupport on Twitter and/r/firefox on Reddit.

Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Why inline css property with !important not override the class property in firefox ?

  • 4 replies
  • 1 has this problem
  • 2 views
  • Last reply by cor-el

more options

Why inline css property with !important not override the class property in firefox ?

We try to replicate the same thing in Chrome and there it overrides correctly but in firefox it shows problem

Let me try to clear the scenario

we have a class

.top-container { display: none !important }

and on element we add style

element.style. display = 'block !important;'

but it don't show the element. While in Chrome (OS MAC) it work fine

My System Configuration

OS - MAC

Firefox Version - Firefox 59.0.2.dmg

There is some issue in attaching snapshot. So I put a stackoverflow link where snapshots are present. Please have a look

https://stackoverflow.com/questions/49760154/is-there-anyway-that-inline-css-property-with-important-not-override-the-class

Why inline css property with !important not override the class property in firefox ? We try to replicate the same thing in Chrome and there it overrides correctly but in firefox it shows problem Let me try to clear the scenario we have a class .top-container { display: none !important } and on element we add style element.style. display = 'block !important;' but it don't show the element. While in Chrome (OS MAC) it work fine My System Configuration OS - MAC Firefox Version - Firefox 59.0.2.dmg There is some issue in attaching snapshot. So I put a stackoverflow link where snapshots are present. Please have a look https://stackoverflow.com/questions/49760154/is-there-anyway-that-inline-css-property-with-important-not-override-the-class

All Replies (4)

more options

Please always check your code with upload or direct URL link with W3C.org (World Wide Web Consortium) in charge of standards and practices and future development of web pages and web browsers make the rules on code. Mozilla Firefox follows these rules. W3C.org Who make the rules for web code. HTML https://validator.w3.org/ CSS https://jigsaw.w3.org/css-validator/ and https://validator.w3.org/i18n-checker/ and http://mobile.css-validator.org/

more options

Hi , I read those rules that's why I am asking why it behave differently.

Is there any bug in firefox, may be due to long selector ? 

If you need more details to reproduce this bug please let me know

Modified by abhaygarg12493

more options

Hi if you have the page up and running some where please supply the URL and someone will look at all your code that knows more than I. As the error may not be where you think it is. Meta tag it with No robots, no index and we can see it while others will not.

Staying away from Moz work arounds is always the best.

I will forward this question now as it stands.

more options

Any special reason for using the !important flag since that will possibly makes it less easy to override CSS properties?

The Specificity of a class might be higher than an inline rule and you may not be able to override it..