Search code examples
htmlcssmargins

If IE Statements not working


<!--[if lt IE 7]>  <html class="ie ie6 lte9 lte8 lte7"> <![endif]-->
<!--[if IE 7]>     <html class="ie ie7 lte9 lte8 lte7"> <![endif]-->
<!--[if IE 8]>     <html class="ie ie8 lte9 lte8"> <![endif]-->
<!--[if IE 9]>     <html class="ie ie9 lte9"> <![endif]-->
<!--[if gt IE 9]>  <html> <![endif]-->
<!--[if !IE]><!--> <html>             <!--<![endif]-->

The above code, does not seem to work in the least bit. The only IE version that my website(The Randy) seems to work in is IE9. I thought it was working because of the conditional statements I've input above, but it works in IE9 without those statements as well. If I look at it in IE8 and IE7 I get a broken looking website. Any help would be most appreciated.


Solution

  • Conditional comments are not supported in IE 10 and are a bad idea anyway, especially since standards have been set.

    You should ALWAYS use feature detection instead of browser detection.


    EDIT: Reading the Console helps too:

    HTML1513: Extra "<html>" tag found. Only one "<html>" tag should exist per document.
    therandy.tk, line 9 character 20

    HTML1503: Unexpected start tag.
    therandy.tk, line 12 character 1

    HTML1512: Unmatched end tag.
    therandy.tk, line 245 character 208

    HTML1514: Extra "<body>" tag found. Only one "<body>" tag should exist per document.
    therandy.tk, line 247 character 1

    HTML1519: Invalid nesting. An "<a>" tag should not be placed within another "<a>".
    therandy.tk, line 364 character 97