• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

When use !important ?

Jaxel

Well-known member
#3
CSS will always use the MOST DESCRIPTIVE declaration.

So...
Code:
td { padding: 5px; } // least important
tr td { padding: 5px; }
table tr td { padding: 5px; }
body table tr td { padding: 5px; }
html body table tr td { padding: 5px; } // most important
If you can, always try to use a more descriptive declaration instead of using !important. However, if you must, there is really no technical harm in using it; don't let people like the author of the above article scare you. The real issue you will have is if you are writing addons, as the code may interfere with some people's skins.
 

MagnusB

Well-known member
#5
I don't think the article is trying to scare, it is just exemplifying good practice. Using higher specificity over !important is always the better option, and in the long run more maintainable. xF is built up that way, otherwise we could not have had so many shared css classes between completely different elements.