Forum Moderators: open
I'm working on a page that just isn't right in IE 5 or 5.5. I intend to figure out why sometime in the near future, but for now I just need to get this page functional, almost no matter what it takes. So I decided to use IE Conditional Statements to give it a little different CSS.
However, I can't seem to get only IE 5.5 and 5.0 to recognize the conditional statements. It seems that no matter what I try, IE 6 also renders the code. Here are a couple of things I've tried:
<!--[if lte IE5.5]>
<!--[if lt IE6]>
<!--[if IE5.5]>
<!--[if IE5]>
And all of the above with a space added between "IE" and the version number, like this:
<!--[if lte IE 5.5]>
No matter what I've tried, the statements either affect all versions of IE, or none. So what am I missing? It seems so simple, but something isn't right.
Thanks,
Matthew
I think I figured out the problem, too. I had been using the correct syntax for the conditional statements, but was testing with IE 5, 5.5 and 6 on the same machine (per DrDoc's tutorial). I think that probably the conditional statements aren't interpreted correctly under those circumstances. At least that's the only solution I could come up with.
And to go completely off-topic, has anyone noticed how really good IE 6 is compared with IE 5.x when it comes to CSS support? I mean, we gripe about how badly IE does CSS, and it's true that even IE 6 isn't as good as most other browsers, but it's sure a big improvement in the IE family!
I had been using the correct syntax for the conditional statements, but was testing with IE 5, 5.5 and 6 on the same machine (per DrDoc's tutorial). I think that probably the conditional statements aren't interpreted correctly under those circumstances. At least that's the only solution I could come up with.
This is my experience. They're definitely not executed correctly if you have more than one version open at the same time, but I think they do work if you open the versions at diferent times.
However, if you're trying to hide CSS rules, why not use a CSS hack [centricle.com] to hide them?
They sort of work - if you can actually understand Microsoft's instructions as to how to use them - but there are all kinds of potential pitfalls. Not the least of these pitfalls is the problem with testing diferent versions of IE.
But where CSS hacks win hands down is that you only have to have one hack, in your style sheet file. Conditional statements have to be scattered throughout your web site, making maintenance changes a potential nightmare.
(If course, if you generate your HTML via a server-side application, then this latter problem doesn't exist.)
Conditional statements have to be scattered throughout your web site, making maintenance changes a potential nightmare.
You could just add..
<!--[if IE 5]>
<link rel="stylesheet" type="text/css" media="all" href="/styles/ie5.css">
<![endif]-->
(I usually go one step further and use a server side script that only adds these lines to the HTML if the user agent indicates that the browser might be from the IE5.x family. But that step is entirely optional and just an extra little benefit of using dynamic pages.)
You could just add..<!--[if IE 5]>
<link rel="stylesheet" type="text/css" media="all" href="/styles/ie5.css">
<![endif]-->
..to the head of each page, which doesn't seem particularly complicated or difficult to maintain to me.
It depends how many pages there are. I grant it's not complicated, but it could be overwhelming :-)
It's an option and so is using a CSS hack. There's no general answer as to which to use, applicable under all circumstances. You just have to be aware of the plusses and minuses of each method and choose the best one for you in the context of whatever it is you're doing. I've used both under different circumstances, and will no doubt continue to do so.