IE7 compatability hacks
Hi Guys,
I've just tried adding a css file purely for IE7 and below using the attached hack:
in the index.php head of a site I'm working on
I've not added many changes, just removed the background image and changed the background colour to see if it works. When it does, I'll do it properly.
There's the rub, it doesn't seem to work at all.
Any idea what I'm doing wrong?
Thanks in advance
Gaspode
Attachment | Size |
---|---|
css.txt | 86 bytes |
Megan posted this at 14:24 — 14th May 2012.
She has: 11,421 posts
Joined: Jun 1999
Here is the code from your web page.
<!--[if lt IE 8]> <link href="ie7.css" rel="stylesheet" type="text/css"> <![endif]-->
<!--[if !IE]>--> <link href="styles.css" rel="stylesheet" type="text/css"> <!--<![endif]-->
That stylesheet loads fine for me in IE 8 with compatibility mode turned on. Maybe you need to clear the cache or something? Make sure you have compatibility mode checked if you're using IE 8. The changes you mentioned don't appear to be in the ie7.css file - there's still a background image and the background colour is the same.
Are you really going to serve a completely separate stylesheet to IE vs. other browsers? Usually you would serve a standard stylesheet to all browsers, including IE, and then just add on some fixes for IE where necessary.
Finally, conditional comments aren't really a "hack". They were created deliberately by Microsoft for this very purpose (although they are no longer supported in IE9). Hacks exploit deficiencies or differences in the way browsers interpret certain characters in a stylesheet. They depend on something the browser does unintentionally, which could be fixed at any time. That's what makes hacks a shaky thing to rely on for your CSS.
Megan
Connect with us on Facebook!
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.