ollyatstithians
asked on
Using <comment> tag to reverse IE conditional comments
I want an image to be used in IE, but a different one to be used in other browsers. I can get the IE image to display only in IE by using conditional comments. I can also get the non IE image not to display in IE by using the non-standard <comment> tag.
The problem with this is that it makes my HTML invalid. My solution was to enclose the <comment> tag and its corresponding </comment> in conditional comments, so that Firefox et al ignored it, making the page valid once again.
The idea seems sound to me, but sadly the closing </comment> does not work in a conditional comment. Probably because IE is waiting for the closing comment before it evaluates the condition. My code is below. Any solutions to this?
Thanks,
Olly.
The problem with this is that it makes my HTML invalid. My solution was to enclose the <comment> tag and its corresponding </comment> in conditional comments, so that Firefox et al ignored it, making the page valid once again.
The idea seems sound to me, but sadly the closing </comment> does not work in a conditional comment. Probably because IE is waiting for the closing comment before it evaluates the condition. My code is below. Any solutions to this?
Thanks,
Olly.
<!--[if IE]>
<img src="img/IEImage.jpg" alt="This image should be displayed only in IE">
<comment>
<![endif]-->
<img src="img/OtherImage.png" alt="This image should never be displayed in IE">
<!--[if IE]>
</comment>
<![endif]-->
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER