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, isnot good practice and should be avoided. Because it does debug more difficult by breaking the naturalcascadingin your stylesheets. When two conflicting declarations with the
!importantrule 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.