views:

22

answers:

3

basically I'd like to know if this code is ok

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

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]-->
RoToRa
thanks, my trouble is that the body may or may not have an id depending on a server side script, looks like I'll have to find another solution
mjr
@mjr why not let the server side script handle it then?
Pekka
ya ... I'm not familiar with browser sniffing on the server side
mjr
Why would the fact may or may not have an id, influence on whether or not you can use Conditional Comments?
RoToRa
A: 

No — comments cannot be inserted inside tags.

You
A: 

No, and it's not necessary. Always give the class to the body element and leave the CSS .ie definition empty for all browsers but IE6:

.ie6 {
<!--[if lt IE 7]-->
    ... ugly ie6 hack ...
<!--[endif]-->
}
</style>
<body class="ie6">
Aaron Digulla
good thought, but that limits me to one version of ie in the classIf I wanted to add and ie7 or ie8 class in the future, I don't know if this would be the best solution
mjr
Why? You can add as many classes to a single element as you need (separate them by space) or you could use `ie` as the generic class and then put a lot of `if`s inside of the CSS.
Aaron Digulla