0
Pls what is the use of !Important in css
2 Answers
+ 5
!important is used to override the styles applied for some specific property.
=ā======================================
For example:-
<div id="demo">some content</div>
#demo{
background-color : red;
}
div{
background-color: blue;
}
=ā======================================
As per the above code, the background color of div will be "red" and not "blue".
This is because, the id has more specificity than tag. So inorder to override all the previous style applied, !important is used.
=ā======================================
#demo{
background-color : red;
}
div{
background-color: blue !important;
}
=ā======================================
Now the background-color will be "blue" because the !important will force to override the previous style.
For more info, check about css specificity to understand better.
+ 1
Thanks