CSS Tutorial
CSS Advanced
CSS Responsive
CSS Grid
CSS !important
What is important?
The important rule in CSS gives more importance to a property/value than normal.
Using the important rule, override ALL previous styling rules for that specific property on that element.
Let us look at an example.
HTML
This is some text in a paragraph.
This is some text in a paragraph.
This is some text in a paragraph.
CSS
#myid {
background-color: blue;
}
.myclass {
background-color: gray;
}
p {
background-color: pink
!important;
}
Output

Example Explained
In the example above. all three paragraphs have a red background color, even though the ID selector and the class selector have a higher specificity. The! The important rule takes over the background-color property in both cases.
About !important
The only way to override an! important rule is to include another ! important rule on a declaration with the same specificity in the source code – but this results in making the CSS code confusing and the debugging will be hard, especially if you are using a large style sheet!
HTML
This is some text in a para.
This is some text in a para.
This is some text in a para.
CSS
#myid {
background-color: blue !important;
}
.myclass {
background-color: gray !important;
}
p {
background-color: pink !important;
}
Output
