Posted By

michellebracken on 08/18/11


Tagged


Versions (?)

Understanding !important


 / Published in: CSS
 

!important is a way to override CSS specificity. In general it’s not the best solution since the more you use it, the more you end up needing to use it again. It can make your CSS unmaintainable in a hurry. It can be useful due to a quirk in IE. When you have something like the following

browsers should show the h1 with a color red. IE, however will show the style that comes last instead of following the rules of precedence. So the code would show your h1 as red in all browsers except IE where the color would be blue.

  1. 1 h1 {
  2. 2 color: red !important;
  3. 3 color: blue
  4. 4 }

Report this snippet  

You need to login to post a comment.