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:
- You have a global CSS file that sets visual aspects of your site globally.
- or you have to use an inline style element. it’s very bad practice.
- in WordPress when you use the WordPress plugin and you want to style it you use
!importantfor overwriting the style.