Update: Yes, LESS can help.
I hate using !important except in the most extreme circumstances. Most people use it as a chainsaw when they need to use scalpal to do the job. However, I understand the problems faced by widget developers like you, and your choice to use https://github.com/premasagar/cleanslate leaves you without an option.
Marc answer noted the good LESS feature, but he was unable to demonstrate how this could help in this matter.
If you complete all of the LESS code in intermediate mixing with names, this function does exactly what you need. So, suppose your widget code looks like this (you mentioned that you are already using some class for your widget):
.yourWidgetClass div > p { prop: something; &:hover { prop: some-hover-style; } } .yourWidgetClass .someClass { prop: something; }
Then you can do this (wrapping all your widget code in #makeImportant() , and then calling this mixin with the !important function noted in Marc's answer):
#makeImportant() { .yourWidgetClass div > p { prop: something; &:hover { prop: some-hover-style; } } .yourWidgetClass .someClass { prop: something; } } & { #makeImportant() !important; }
The result is the following CSS output:
.yourWidgetClass div > p { prop: something !important; } .yourWidgetClass div > p:hover { prop: some-hover-style !important; } .yourWidgetClass .someClass { prop: something !important; }
For my original (accepted) answer, which was more intense in manual mode, see the change history.
source share