Search code examples
conditional-comments

IE conditional content showing up on chrome mobile


My HTML content is divided up into two sections: one that displays on IE8 and older, and one that shows up on ie9+ or "not IE". This seems to work fine on desktop, but when viewing via chrome mobile, I am seeing the IE8 stuff as well.

Any thoughts?


Solution

  • Never mind, I fixed it. Here is the solution:

    Original code (outline):

        <!--[if lte IE 8]>
        <div id="section-1">
            CONTENT HERE
        </div><!-- Comment after -->
        <div id="section-2">
            CONTENT HERE
        </div><!-- Comment after -->
    <![endif]-->
    

    As the conditional comments create one long comment starting from the "if" and ending with the "endif", by adding comments at the end of "section-1" and "section-2", I was effectively ending the comment at that point rather than at the "endif". Everything after the accidental comment end was being displayed by the browser.