onetwo12
onetwo12

Reputation: 2439

Internet Explorer 8 DOCTYPE ignored/commented

I am trying to make my web application work in IE8. There are some problems with the Offset and placement of some elements.

The application works fine in Chrome, Safari, Firefox and IE9/10 but when I set the "Document Mode" for IE8 this <!DOCTYPE html> is commented like this <!-- DOCTYPE html --> if I put the "Document Mode" back to IE9 it is fine.

I have tried using other declarations

<!DOCTYPE>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

but I get the same result commented string in IE8.

How can I make IE8 accept doctype?

UPDATE:

I think that you are right Jukka K. Korpela, I have noticed now that even when I open google.com it has commented doctype in IE8.

My app in IE9:

This is how my app looks like in IE9

My app in IE8:

This is how my app looks like in IE8

The offset is -250 in IE8.

Upvotes: 3

Views: 2384

Answers (1)

Spudley
Spudley

Reputation: 168685

<!DOCTYPE html> should be fine for making IE go into standards mode.

The most common reason it doesn't work is because you have some other content ahead of it. The doctype must be the very first thing in the page -- even white space above it can make it invalid.

Also, if your files are saved with UTF-8 encoding, make sure that it is "UTF-8 Without BOM", because the invisible BOM (byte order mark) at the start of the file can also have the same effect.

Hope that helps.

Upvotes: 1

Related Questions