!important CSS Declarations: How and When to Use Them
smashingmagazine.com
smashingmagazine.com
Perhaps I have been programming in C for too long.
But now that you've mentioned it, @important would be a lot more intuitive.
When you have a user stylehseet loaded on top of a website's existing stylesheets.
This could happen when:
- using something like the UserStyles plugin for firefox
- a website allows users to load custom stylesheets into widgets
(like facebook used to do with their social plugins)
... but I agree that there isn't really a good justification for using the !important declaration if you have full control over stylesheets.It's about on par with sticking magic constants in your code.
If someone has a better solution for that please tell me!
An inline style will always override a rule in a stylesheet… unless the rule uses !important.
Using mostly CSS classes helps you avoid the need for !important.