Posts Tagged ‘ie7 hack’

IE hacks within standard CSS

Tuesday, May 31st, 2011

Updated! To include IE8 hacks

I do not like using conditional statements to load up another stylesheet for IE (Internet Explorer) . . . so it’s always a pain for me to make sure IE behaves. Normally, I’m successful and on those moments when I’m not, I just use these simple hacks – putting an asterisk(*) right before the style will be applied to IE’s v.6 and v.7 browsers while all other ignore it . . . and if you specifically just want to target IE v.6, then use the underscore(_). For IE8, look at the sample code below:

here’s an example:

margin:10px; /* works in all */
margin-top /*\**/:10px\9 /* targets IE8 */
margin-top:10px\9 /* targets IE6, 7 & 8 */
*margin:10px; /* targets IE6 and 7 */
_margin:10px; /* targets IE6 */