views:

31

answers:

2

Hi, I need to have a slightly different HTML element in IE7 than the rest, here is what I have so far:

<p>
        <label>&nbsp;</label>

        <!--[if IE 7]>
        <span class="progressIndicator" style="display: none;"></span>
        <button type="submit" class="submit" value="" id="qsubmit">SEND</button>
            <![endif]--> 

            <span class="progressIndicator" style="display: none;"></span>
        <button type="submit" class="submit" value="" id="qsubmit">&nbsp;</button>

    </p>

But this just displays the button twice, one with the correct value, and one that doesn't work as desired.

What's the correct way to replace this HTML element for IE7 only?

I would prefer not to browser sniff.

Thanks :)

+2  A: 

Like this:

    <!--[if IE 7]>
    <span class="progressIndicator" style="display: none;"></span>
    <button type="submit" class="submit" value="" id="qsubmit">SEND</button>
    <![endif]--> 



    <!--[if !(IE 7)]><!-->
    <span class="progressIndicator" style="display: none;"></span>
    <button type="submit" class="submit" value="" id="qsubmit">&nbsp;</button>

    <!--<![endif]--> 
SLaks
Thanks, solved it. But one thing I didn't think about was now it doesn't display at all in non IE browsers.
Kyle Sevenoaks
I fixed the syntax a minute ago; this should now display in non-IE browsers.
SLaks
+1  A: 

Put the non-IE7 content in a downlevel-revealed conditional comment (though note the syntax MS use in that article is unnecessarily-invalid HTML). Simplified from the seemingly-redundant markup in the question:

<p>
    <label>&nbsp;</label>
    <span class="progressIndicator" style="display: none;"></span>
    <button type="submit" class="submit" value="" id="qsubmit">
        <!--[if lt IE 8]>
            SEND
        <![endif]--> 
        <!--[if gte IE 8]><!-->
            &nbsp;
        <!--<![endif]-->
    </button>
</p>
bobince
Thanks, works perfectly :)
Kyle Sevenoaks