Is it possible to make the entire .class CSS selector important? I'm thinking in this kind of structure:
.custom-selector !important { display: inline-block; vertical-align: middle; position: relative; padding-left: 5px; }
I don't know if it's possible.
important rule in CSS is used to add more importance to a property/value than normal. In fact, if you use the ! important rule, it will override ALL previous styling rules for that specific property on that element!
As a special case for increasing specificity, you can duplicate weights from the CLASS or ID columns. Duplicating id, class, pseudo-class or attribute selectors within a compound selector will increase specificity when overriding very specific selectors over which you have no control.
No, it's not possible. !important
is thought to be an instrument of last resort and as such should be used sparingly. !important
ing whole selectors would caricature that idea.
If you need to trump other styles, use CSS specificity to your advantage. You can use, e.g., these techniques to push your style declarations to the top:
double class name will trump single class name:
.custom-selector.custom-selector > .custom-selector
ID trumps class:
#custom-id > .custom-class
IDs can be duplicated, too:
#id#id > #id
inline styles trump any stylesheets:
<style> p#id#id.class.class { color: green; } </style> <p id="id" class="class" style="color:red">I am red!</p>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With