Skip to main content
Commonmark migration
Source Link

###What's wrong with !important:

What's wrong with !important:

###When is it okay to use:

When is it okay to use:

###Conclusion

Conclusion

###What's wrong with !important:

###When is it okay to use:

###Conclusion

What's wrong with !important:

When is it okay to use:

Conclusion

added 245 characters in body
Source Link
Stephan Muller
  • 27.7k
  • 18
  • 89
  • 127

Yes, I'd say your example of using !important is generally bad practice, and it's very likely it would cause undesired effects further down the line. That doesn't mean it's never okay to use though.

###Why it's bad practice###What's wrong with !important:

Using the !important declaration is often considered bad practice in mostbecause it has side effects that mess with one of CSS's core mechanisms: specificity. In many cases, asusing it most likely indicatescould indicate poor CSS architecture. 

There are cases in which it's tolerable or even preferred, but make sure you double check that one of those cases actually applies to your situation before using it.

Yes, !important is generally bad practice.

###Why it's bad practice:

Using the !important declaration is considered bad practice in most cases, as it most likely indicates poor CSS architecture. There are cases in which it's tolerable or even preferred, but make sure you double check that one of those cases actually applies to your situation before using it.

Yes, I'd say your example of using !important is bad practice, and it's very likely it would cause undesired effects further down the line. That doesn't mean it's never okay to use though.

###What's wrong with !important:

Using the !important declaration is often considered bad practice because it has side effects that mess with one of CSS's core mechanisms: specificity. In many cases, using it could indicate poor CSS architecture. 

There are cases in which it's tolerable or even preferred, but make sure you double check that one of those cases actually applies to your situation before using it.

added 66 characters in body
Source Link
Stephan Muller
  • 27.7k
  • 18
  • 89
  • 127
button { 
    color: black; 
}
button.highlight { 
    color: blue; 
    font-size: 1.5em;
}
button#buyNow { 
    color: green; 
    font-size: 2em;
}
button { 
    color: black; 
}
button.highlight { 
    color: blue; 
    font-size: 1.5em;
}
button#buyNow { 
    color: green; 
    font-size: 2em;
}
button.highlight {
    color: blue !important;
    font-size: 1.5em;
}
button.highlight {
    color: blue !important;
    font-size: 1.5em;
}
button { 
    color: black; 
}
button.highlight { 
    color: blue; 
    font-size: 1.5em;
}
button#buyNow { 
    color: green; 
    font-size: 2em;
}
button.highlight {
    color: blue !important;
    font-size: 1.5em;
}
button { 
    color: black; 
}
button.highlight { 
    color: blue; 
    font-size: 1.5em;
}
button#buyNow { 
    color: green; 
    font-size: 2em;
}
button.highlight {
    color: blue !important;
    font-size: 1.5em;
}
Minor phrasing changes and serial comma addition, as well as dependent clause denotation
Source Link
TylerH
  • 21.3k
  • 86
  • 84
  • 122
Loading
added 1968 characters in body
Source Link
Stephan Muller
  • 27.7k
  • 18
  • 89
  • 127
Loading
Encoded !important everywhere it was used for readability, revised grammar and fixed some spelling mistakes.
Source Link
TylerH
  • 21.3k
  • 86
  • 84
  • 122
Loading
syntax highlighting hint for css
Source Link
BoltClock
  • 729.1k
  • 165
  • 1.4k
  • 1.4k
Loading
syntax highlight hint for html
Source Link
BoltClock
  • 729.1k
  • 165
  • 1.4k
  • 1.4k
Loading
Source Link
Stephan Muller
  • 27.7k
  • 18
  • 89
  • 127
Loading
deleted 4 characters in body
Source Link
Stephan Muller
  • 27.7k
  • 18
  • 89
  • 127
Loading
added 88 characters in body
Source Link
Stephan Muller
  • 27.7k
  • 18
  • 89
  • 127
Loading
deleted 2 characters in body
Source Link
BoltClock
  • 729.1k
  • 165
  • 1.4k
  • 1.4k
Loading
Source Link
Stephan Muller
  • 27.7k
  • 18
  • 89
  • 127
Loading