Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE9 throws my page in IE7 document mode and <!DOCTYPE html> gets commented out

My webpage has the following doctype

<!DOCTYPE html>

The above line is the very first line on my HTML page. These are no extra spaces or comments before this line. Still the page goes in IE7 document mode and <!DOCTYPE html> gets commented out when i check the html page using developer tools.

I know that I can force a certain document mode by including the following meta tag

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

But I am not supposed to use this, niether I am supposed to go to tools and change the compatibility view settings (Tools -> Compatibility view settings).I have also checked whether the document is valid HTML5 document using a HTML5 validator.

Some solutions I searched were of CSS causing this problem ie. beacuse of using Type 1 font (Helevetica). I checked my css and nowhere we are using this font.

Basically I need to know what are the reasons that is causing this unusual behaviour. Is it some css or javascript that is causing this.

EDIT : as mentioned in one of the comments I tried loading a simple html page as follows

<!DOCTYPE html>
  <html>
   <head>

   <title>Hello Wrold</title>
   </head>
   <body>
      <div>hello world!!</div>
   </body>
  </html>

It is behaving the same way. Page loads in IE7 document mode.

like image 910
tiger Avatar asked Nov 13 '22 04:11

tiger


1 Answers

Check your html file and make sure there is no BOM (Byte Order Mark) at the beginning of the document. This can cause problems in some browsers. In order to check, use something like Adobe Dreamweaver or Notepad++. Open file in ANSI mode in notepad and check if there are characters before, delete them and save as UTF-8 without bom (option when saving in notepad++)

like image 55
LMark Avatar answered Nov 14 '22 22:11

LMark