htmlinternet-explorerconditional-comments

Can I include IE conditional comments inside an opening tag?


Basically, I'd like to know if this code is okay,

<body id="some_id" <!--[if lt IE 7 ]>class="ie6"<![endif]--> >
</body>

Solution

  • No. HTML comments can't be inside a tag. Try:

    <!--[if gte IE 7]>--> <body id="some_id"> <!--<![endif]-->
    <!--[if lt IE 7]> <body id="some_id" class="ie6"> <![endif]-->