Loading Please Wait...
The CSS !important rule in CSS is used to add more importance to a property/value than normal.
If we use the !important rule, it will override all previous styling rules for that specific property on that element!
#sectionID {
background-color: blue;
}
.sectionClass {
background-color: gray;
}
p {
background-color: red !important;
}
In the above example ID selector has the highest specificity among all the selector. But !important rule overrides all the definition and apply style (background-color: red;) to all selections.
The only way to override an !important rule is to include another !important rule on a declaration with the same (or higher) specificity in the source code - and here the problem starts! This makes the CSS code confusing and the debugging will be hard, especially if you have a large style sheet!
#sectionID {
background-color: blue !important;
}
.sectionClass {
background-color: gray !important;
}
p {
background-color: red !important;
}
Declaring a shorthand property with !important sets all of sub-properties as important.
p{
margin: 10px !important;
}
/* It will mark the individual properties as !important too. */
#p{
margin-top: 10px !important;
margin-right: 10px !important;
margin-bottom: 10px !important;
margin-left: 10px !important;
}
How you feel about this blog:
Share this blog on:
If you find any error in the turtorials, or want to share your suggestion/feedback, feel free to send us email at: info@lynxsia.com
Contact UsWe are concern with various development process like website design & development, E-commerce development, Software development, Application development, SMS & Bulk SMS Provider, PWA Development, and many more..
Copyright ©
, Lynxsia IT Solutions, All rights reserved