How !important tag is important in CSS?
December 8, 2009 - CSS3 CommentsPrecedence is the word which comes in mind when we speak about !important tag.
Yes Definitely CSS tag !important rules by taking its precedence over later rules. Normally CSS starts its precedence from top to bottom, but when we add this !important tag CSS changes its rule by giving entire precedence to particular property value.
Below you will find some examples which gives you the better idea about it,
1. Normally in CSS
color: red;
}
p{
color: black;
}
In the above example the highlighted one that is property with the value black will take the precedence, in which CSS normally do.
2. using !important tag
color: red !important;
}
p{
color: black;
}
Yes in the above example you can find some difference. The highlighted one will holds its precedence that means the property paragraph holds its value finally as red now.
3. Now question arises for you is if we applied !important tag to both the properties, what is the final value?
color: red !important;
}
p{
color: black !important;
}
In the above example CSS plays its normal role from top to bottom and puts its value as black.













Hi sada, i understand but my question is how this !important tag will work if you apply inline style?
Absolutely no gavick, if you applied !important tag in external CSS and try to make any changes its value using inline style it doesn’t work, because external style value will take its precedence.
I am wondering if someone can put a bit of an authoritative reference summary of when the !important declaration in CSS does not work to override inline styles.