CSS HACKS
We have lots of ways to HACK CSS. However, these are the couple I find most useful.
Star-property Hack
*property: value;
Not sure on the name but I call this the star-property hack. This hack allows you to target IE7 and below.
Underscore-property Hack
_property: value;
This targets IE6 and below. Any styles will be applied to ie 6 and below.
!important Targetting
The !important at the end of a style, tells browsers that this property should override any other declarations of that property regardless of position. For example in this case:
width: 10px !important;
width: 80px;
Even though the 80px declaration comes second, Firefox 3 and IE7/8 will render this style as 10pixels. IE6 does not recognize the !important declaration and will apply an 80pixel width.
I prefer this method when I need to target IE7 and FF with one rule, and IE6 with the other. This is a valid method of feeding one rule to ie7/ff and another for ie6.
CSS Examples
div.test{
margin-top: 10px; //firefox
*margin-top: 15px; //ie7
}
div.test{
margin-top: 10px; //firefox
*margin-top: 5px; //ie7
_margin-top: 2px; //ie6
}
div.test{
margin-top: 10px !important; //ff and ie7
mragin-top: 2px; //ie6
}
NOTE: The star property hack and the underscore property hack are NOT valid css, but sometimes you need to get a little dirty to fix IE7 and IE6 issues. With the release of IE8, hopefully the inconsistencies of cross browser css will finally be ironed out, however people will still insist on using IE7...so knowing how to support it is important.
Hope you enjoyed with your hacked css.
contant reference : http://theinfiniteloopblog.com/tag/cross-browser-css/
Star-property Hack
*property: value;
Not sure on the name but I call this the star-property hack. This hack allows you to target IE7 and below.
Underscore-property Hack
_property: value;
This targets IE6 and below. Any styles will be applied to ie 6 and below.
!important Targetting
The !important at the end of a style, tells browsers that this property should override any other declarations of that property regardless of position. For example in this case:
width: 10px !important;
width: 80px;
Even though the 80px declaration comes second, Firefox 3 and IE7/8 will render this style as 10pixels. IE6 does not recognize the !important declaration and will apply an 80pixel width.
I prefer this method when I need to target IE7 and FF with one rule, and IE6 with the other. This is a valid method of feeding one rule to ie7/ff and another for ie6.
CSS Examples
div.test{
margin-top: 10px; //firefox
*margin-top: 15px; //ie7
}
div.test{
margin-top: 10px; //firefox
*margin-top: 5px; //ie7
_margin-top: 2px; //ie6
}
div.test{
margin-top: 10px !important; //ff and ie7
mragin-top: 2px; //ie6
}
NOTE: The star property hack and the underscore property hack are NOT valid css, but sometimes you need to get a little dirty to fix IE7 and IE6 issues. With the release of IE8, hopefully the inconsistencies of cross browser css will finally be ironed out, however people will still insist on using IE7...so knowing how to support it is important.
Hope you enjoyed with your hacked css.
contant reference : http://theinfiniteloopblog.com/tag/cross-browser-css/
Comments