> Ehhhh, sometimes `!important` is a good option. I agree that just for the 'quick fix' it's a bad idea, but it can solve other issues beautifully.
`!important` is the GOTO of CSS.
In general you're not supposed to use it, but if you do, it makes some things much simpler.
If you've reached the point where you know the right time to use !important, you probably already know its bad and most likely don't need any of this advice.
Yes, if you are building something that should look the same across websites, this is a good idea.
Though it's often better to just have your own iFrames and use cross-domain communication, since your plugin will have to do its own authentication and API as well.
If you're writing a module, best to prefix each class with some abbreviation. `#MyModuleName .mmn-foo` ... much less likely to clash, still need the `#MyModuleName div` reset, but it's better than dealing with weird integration issues.
Yeah, and possibly break font-size and contrast changes for the visually impaired, if it's not scoped right - break printing ... in general I'd say you're more likely to create an issue than not, using !important.
In my experience working with a lot of CSS frameworks there are times where not using !important would make the site too brittle if layout had to be changed.
When it comes down to abusing selector nesting vs using !important, use !important.
With style classes you don't run in to the issue of needing to then override the !important rule w/ another important rule - you would just remove the style class.
Ehhhh, sometimes `!important` is a good option. I agree that just for the 'quick fix' it's a bad idea, but it can solve other issues beautifully.
For example: If you're writing a plugin or some sort of module that will inject a block of styled content in websites whose normal styling you have no control over, and you need to not accidentally let the sites override your own styling, it's a great fit.
In that situation, it's used to ensure that your block will display correctly across thousands or millions of websites and not fall victim to some awkward accidental local CSS rule like `#body #content #post strong {}` that some developer thought was a clever idea at one point, but didn't realize the implications of the insane level of specificity that is assigned. (I've seen this happen and the support load that it causes).
Far better to have reasonable selectors targeting only your markup, with `!important` so that sites, if they want to, can override your styling, but they just need to be explicit about it.
Long story short, rigidly holding to rules like these in /all/ situations can lead to far worse results for your users than taking them with a grain of salt and making educated decisions while understanding the implications.