What is the !important property in CSS?

The !important property in CSS means that all subsequent rules on an element are to be ignored, and the rule denoted by !important is to be applied. This rule overrides all previous styling rules ​-- the !important property increases its priority.

svg viewer

Syntax

The !important property is mentioned immediately before the semicolon:

h1 {
  background-color: red !important;
}

Code

In the example below, the normal color for the h1 tag was blue but, because of the !important property, a different color is applied. Similarly, a different color is applied to the background instead of red:

Free Resources

Copyright ©2024 Educative, Inc. All rights reserved