Using !important With CSS

CSS Web Development

I am not a “quick fix” or “work around” type of person. When a CSS debugging project comes my way I look first at fixing the problem systemically vs. applying the quick fix. Recently though I was brought into a project with an insane amount of CSS and conflicting styles all over the place. Since I did not have ample time to fix the issues systemically (this was a super stat job) I was forced to use something that would take precedence over the problematic styles already in place to quickly fix the issues.

If you have worked with CSS before I am sure you have seen “!important” used but probably were not really sure what it was. I ended up using a “fixes.css” style sheet which was called in after all the other style sheets and then using “!important” with the styles I needed to correct (override). This was very helpful and if you ever run into a similar situation or have a certain style that you cannot seem to figure out why something is not showing up (“I set this to have a margin-bottom:20px; but there is no margin at all”) try putting in the !important (margin-bottom:20px !important;) and see if that helps.

More information on !important: http://www.w3.org/TR/REC-CSS2/cascade.html#cascading-order

Leave a Reply

Your email address will not be published.
*
*

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Games

Working Out With the Wii

Over the weekend I was showing a friend my Wii and all the games we have and we decided to focus on boxing. My initial response to boxing was that is was kind of lame, but after the computer player got more difficult – each game became more and more of a workout. At the […]

Music

Music and My Life

I listen to music almost all day, everyday. Yesterday I grabbed the latest NIN album from: http://theslip.nin.com and it made me think about how the music stage is really evolving.