Tuesday, July 14, 2009

Internet Explorer CSS "cheats"

I didn't really think that I'll need this, but it came out I did while I was working on the GutscheineRabatte.de website: some things just don't appear the way they should in Internet Explorer while they're perfect in Firefox (or the other way around :). Anyway, there's an easy way with which you can go around this:

(click in the box to highlight the code for copy)
Let me explore that a little bit more: the sign <!-- is recognized by all other browsers as the beginning and the sign --> as the end of a comment section, therefore they're going to ignore anything that is put in between.

Would you want to target a special version of IE, simply add the version number at the very beginning like this: <!--[if IE 6]> for Internet Explorer 6, or <!--[if IE 5.5]> for Internet Explorer 5.5. Also, you can use "lt", "gt" or "lte" and "gte", meaning less than, greater than, less than or equal and greater than or equal (respectively) like this: <!--[if lt IE 6]>

To make sure that you can use different commands for all non-IE and IE browsers, you can set the first set of commands first and the second set (<![If !IE]>...<![endif]> - only recognized by IE) after one another, just like i did above.

No comments:

Post a comment

Dear legitimate commenters, please post your comments below. I'd be happy to receive your feedback; helps me a lot improving, or getting reassurance that I'm doing something really great here.

IMPORTANT! A note to commenters planning on advertising their business in comments: please be informed that I'm NOT going to post your comments but will ALWAYS mark them as SPAM.