When we use !important exception and why we use it


The important the rule is used on a style declaration and this declaration overrides any other declarations. Although technically !important has nothing to do with specificity, it interacts directly with it. Using!important, however, is not good practice and should be avoided. Because it does debug more difficult by breaking the natural cascading in your stylesheets. When two conflicting declarations with the !important rule are applied to the same element, the declaration with a greater specificity will be applied.

You should use it when:

  1. You have a global CSS file that sets visual aspects of your site globally.
  2. or you have to use an inline style element. it’s very bad practice.
  3. in WordPress when you use the WordPress plugin and you want to style it you use  !important for overwriting the style.