Important Usage

It is used  to override the cascade in CSS. The !important syntax appears within a declaration, after the property value and before the semicolon that terminates the declaration.  It has two parts

  • An exclamation mark, used as a delimiter.
  • The important keyword – To mark the end of the declaration.

As shown in the example

p { background: #fff !important; }

A declaration having the !important rule, always takes precedence over any other declaration even above the style attribute of the HTML element. If more than one !important rule is in a style sheet then the latter rule is applied over any given earlier. Hence, it advised to not to use it as it also makes it harder to define any other rules and makes site maintenance more difficult.

CSS important

Back to Tutorial

Specificity Hierarchy
JavaScript

Get industry recognized certification – Contact us

keyboard_arrow_up
Open chat
Need help?
Hello 👋
Can we help you?