Thursday, April 5, 2007

CSS Underscore Hack : IE cross compatibility issue solved

CSS Hack:

Every Developer would have struggled with Cross Browser Compatibilities and that too these days, the things which work with IE doesnt work with FF and vice versa. Once you are into this issue, it is really difficult to make it up. You have to see both the browsers as two pans of a balance.There are so many hacks coming in. One such is "The underscore hack", which can be used almost for all issues.

What is this Underscore Hack issue?
Underscore issue as the name implies is nothing but adding a underscore for every property which behaves differently in IE and FF. Say you have a left margin specification.

left:5px;

But this is not getting properly displayed in IE, IE needs 8 px for that same layout.so the hack is we are adding one more specificaiton which goes like

_left:8px

this "_" specified value will be taken by IE and FF/other browser will take the other value.

But sometimes, we go to an extent of using negative values for proper display using "_", but that is not a standard practise. we should avoid that.

No comments: