IE9 Browser Modes and Conditional Comments

I use the header of the HTML Boilerplate document, which adds various tags to the tag for the IE version. When using IE9 (pressing F12) and changing the browser mode, I seem to remember that the corresponding browser will always be displayed (IE8 / IE7 or IE7 in compatibility mode), however now it does not work.

<!DOCTYPE html> <!-- [if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]--> <!-- [if IE 7]><html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]--> <!-- [if IE 8]><html class="no-js lt-ie9" lang="en"> <![endif]--> <!-- [if gt IE 8]><!--><html class="no-js" lang="en"> <!--<![endif]--> <head> 

The site can be seen at http://rangeessentials.petersenuploads.co.uk/

It also does not work using my IE7 virtual machine. Which I missed since I always get the final tag without IE classes.

+4
source share
1 answer

Instead of having multiple begin <html> tags, which are probably illegal, you should have multiple style sheets, and then the corresponding styles applied respectively in these style sheets:

 <!-- [if lt IE 7]><link type="text/css" rel="stylesheet" href="Styles_IE-7.css" /><![endif]--> <!-- [if IE 7]><link type="text/css" rel="stylesheet" href="Styles_IE7.css" /><![endif]--> <!-- [if IE 8]><link type="text/css" rel="stylesheet" href="Styles_IE8.css" /><![endif]--> <!-- [if gt IE 8]><link type="text/css" rel="stylesheet" href="Styles_IE8-.css" /><![endif]--> 

But even in your code there are <!--> and <!-- in your last conditional comment - this can also be a problem.

0
source

All Articles