CSS Hack !important
In CSS is very easy to overwrite a rule you have created earlier, then you wonder why making changes to the rule doesn’t apply to the page layout.
One thing to know is the !important rule available since CSS1.
Adding !important after a command like this:
.div { margin-left: 5px;color:#ff0000!important;margin-left: 3px;}
will make sure that all browsers will have a margin-left of 5px regardless of what appears after it, except IE (Internet Explorer) which ignores the !important command gives a margin-left of 3px.
This can be very useful when you need to set relative margin as the display will differ from browser to browser.
IE, however, will respect the !important declarations if they are not in the same rule as below:
.div_font {color: red;!important;}
.div_font { color: blue; }
So whatever you asign this rule to the font color will be red not blue as in the second command.
The first example above was a very useful CSS Hack for IE, however since IE7 has been released, the !important rule doesn’t have much effect any longer, as IE7 renders the page much like Firefox.
















