HTML and CSS Reference
In-Depth Information
In this case, the text size was adjustable without using !important ,
because a user-defined stylesheet will override an author stylesheet
regardless of specificity. If, however, the text size for body copy was set in
the author stylesheet using an !important declaration, the user stylesheet
could not override the text-size setting, even with a more specific selector.
The inclusion of !important resolves this problem and keeps the
adjustability of text size within the user's power, even if the author has
abused ! important .
TO TEMPORARILY FIX AN URGENT PROBLEM
There will be times when something bugs out in your CSS on a live client
site, and you need to apply a fix very quickly. In most cases, you should be
able to use Firebug or another developer tool to track down the CSS code
that needs to be fixed. But if the problem is occurring on IE6 or another
browser that doesn't have access to debugging tools, you may need to do a
quick fix using !important .
After you move the temporary fix to production (thus making the client
happy), you can work on fixing the issue locally using a more maintainable
method that doesn't muck up the cascade. When you've figured out a better
solution, you can add it to the project and remove !important — and the
client will be none the wiser.
TO OVERRIDE STYLES WITHIN FIREBUG OR ANOTHER DEVELOPER
TOOL
Inspecting an element in Firebug or Chrome's developer tools allows you to
edit styles on the fly, to test things out, debug, and so on — without a " ecting
the real stylesheet. Take a look at the screen grab below, showing some of
Smashing Magazine's styles in Chrome's developer tools:
Search WWH ::




Custom Search