0

Pls what is the use of !Important in css

10th Oct 2022, 4:53 AM
Elijah Adebanwo
Elijah Adebanwo - avatar
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.
10th Oct 2022, 5:02 AM
Niththish
Niththish - avatar
+ 1
Thanks
10th Oct 2022, 11:29 PM
Elijah Adebanwo
Elijah Adebanwo - avatar