Break your addiction to
!important and make the web a better world.
Within 400 pages of specification, just over half of a page of CSS2.1 is dedicated to discussing !important rules. Most of that discussion relates to the relationship between author style sheets and user style sheets; you know, that feature that no-one ever uses. So the entire body of formal specification relating to “!important”, as it is used today boils down to 2 sentences:
Also, the third author rule will lose to the second author rule since the second rule is “!important”. This shows that “!important” declarations have a function also within author style sheets.
Hardly significant, is it? So why is it I find myself currently working with a
set of style sheets containing some 433
!important declarations? Granted, this
is a lot of CSS I’m dealing with — 8870 lines in total — but that’s still a
hell of a lot of declarations being marked as
It all boils down to the breaking of inheritance and a subsequent slew of
!important rules which attempt to fix the problem, but only serve to heighten it. I’m rapidly reaching the conclusion that
!important should hardly ever be used, and if you find yourself reaching for this ‘safety net’, think again. There’s an obscure IE hack which could, theoretically justify its use but, as you know, I detest hacks with something of a passion, so, ideally, I’d like never to come across the
!important rule ever again. Please.