Today I came across using IE conditional comments, which I had never seen before, and which makes me scratch my head. HTML starts this way
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> ... </html>
I wondered how IE7 would deal with this document. It looks like the document will contain two html tags, the first of which will be closed. Of course, this is not to make out. But it is so. I decided to research.
In IE7 IE9 browser, the html tag ends as
<html class="no-js ie7" lang="en" xmlns="http://www.w3.org/1999/xhtml">
It looks like the attributes from the included html tag of the conditional comment comment merge with the existing html tag. With further manipulations, it seems that the attributes in the conditional html tag are added to the existing tag if they do not already exist in the first html tag. For example:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html class="not so fast" xmlns="http://www.w3.org/1999/xhtml">
leads to:
<html class="not so fast" lang="en" xmlns="http://www.w3.org/1999/xhtml" sizcache="0" sizset="0">
Here, the conditionally included class attribute of the html tag has no effect, since the unconditional html tag already defines the class attribute. Where the sizcache and sizset attributes come from is a complete mystery.
In any case, none of this observable behavior was expected. Microsoft's conditional comment documentation doesnβt mention anything about this use of conditonal comments, and googling came up with a dry one. The page later includes a stylesheet with selectors that reference the ie7 and ie8 classes to override the standard styles in situations where IE 7 and 8 do not display them correctly.
I'm just wondering if anyone has seen this use of conditional comments or knows that this mixing behavior is documented anywhere.