Welcome to WebmasterWorld Guest from 54.162.240.235

Forum Moderators: incrediBILL

Message Too Old, No Replies

Why does IE not like doctypes?

     
8:05 am on Nov 14, 2004 (gmt 0)

WebmasterWorld Senior Member jab_creations is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I have been working on the new version of my site and have it working in XHTML strict. The problem is that I want to be able have show that my site validates as XHTML strict but when I use ANY doctype then IE destroys my layout.

No problems with other browsers; I know IE doesn't like standards but this is ridiculous!

Is there anyway I can have all other browsers except IE see a doctype and even allow W3's validator to see the XHTML strict doctype but not IE? Rendering the page correctly is more important but...well you know.

12:15 pm on Nov 14, 2004 (gmt 0)

10+ Year Member



I am not sure that this is going to be helpful but I have managed to get code that validates to 1.0 transitional and 1.1 strict that displays fine in IE, OK - there are a couple of minor differences at times but essentially the layout works in all browsers.

It does depend on the exact Doctype you are aiming for transitional, frameset etc but maybe the following will help:

Check that you have this as the first line of each page:

<?xml version="1.1" encoding="iso-8859-1"?>
or
<?xml version="1.0" encoding="iso-8859-1"?>

and then for strict 1.1 make sure the Doctype reads:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

and for XHTML 1.0 transitional:

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

It is possible to get code that validates and displays iin both browsers - good luck

12:47 pm on Nov 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<?xml version="1.1" encoding="iso-8859-1"?>

The declarations send IE into quirks mode.

1:14 pm on Nov 14, 2004 (gmt 0)

WebmasterWorld Senior Member jab_creations is a WebmasterWorld Top Contributor of All Time 10+ Year Member



IT WORKS! IE is able to render the page correctly and W3 reads it as a valid page. SCHWEET! Thanks! :-)
1:31 pm on Nov 14, 2004 (gmt 0)

WebmasterWorld Senior Member encyclo is a WebmasterWorld Top Contributor of All Time 10+ Year Member



<?xml version="1.1" encoding="iso-8859-1"?>

One minor correction: you need to declare the XML version as 1.0 not 1.1:

<?xml version="[b]1.0[/b]" encoding="iso-8859-1"?>

This is for any version of XHTML.

1:33 pm on Nov 14, 2004 (gmt 0)

10+ Year Member



ooooooo - interesting. I had it in my pages as 1.0 but then thought that as the doctype declared 1.1 it should be changed. Didn't know it should always be 1.0 and that 1.1 would send it into quirks mode.

Ta!

1:49 pm on Nov 14, 2004 (gmt 0)

10+ Year Member



Having any <?xml... declaration before the <!DOCTYPE...> will send IE into quirks mode, regardless of the content.

Even just a <!-- comment --> will do it.

2:06 pm on Nov 14, 2004 (gmt 0)

10+ Year Member



Adding <?xml version="1.0" encoding="iso-8859-1"?> will cause IE to ignore the DTD and it will render in quirks mode. IE is at least 4 years old and does not fully implement (if at all) the XML media type, and it falls back to quirks mode when it encounters something it doesn't understand.

It is easy to test this, add the line and display the page. IE will be in quirks mode. Remove the line and put the content type in the <head> tag to serve the page as text/html:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Check it again and it will now be in standards mode.

XHTML 1.0 MAY be served as 'text/html','application/xml,'text/xml', but it SHOULD be served as 'application/xhtml+xml. Unfortunately serving it as anything other than 'text/html' causes IE to switch to quirks mode. So for cross browser compatibility it is better to have them all in standards mode, to do that currently you must serve the XHTML as 'text/html'. XHTML 1.1 can not be served as 'text/html'and must use the <?xml version="1.0" encoding="iso-8859-1"?>. So any use of XHTML 1.1 will put IE in quirks mode, and if you serve 1.1 as 'text/html' all browsers will render it in quirks mode.

What I have found that works best for cross browser compatibility is to use XHTML 1.0 served as 'text/html'. It complies with the W3C standards, and all browsers will display it in standards mode. This minimizes the rendering differences between them. It will also be forward compatible for quite a while as new browser versions come out.

It's a confusing topic. Check out W3C, especially the W3C Notes sections, W3 Schools and the many other references on the web to learn more about it.

2:18 pm on Nov 14, 2004 (gmt 0)

WebmasterWorld Senior Member jab_creations is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Umm, how can you tell when IE is in quirks or standards mode?
2:20 pm on Nov 14, 2004 (gmt 0)

10+ Year Member



Thanks Saltminer - clears up some things for me.
2:46 pm on Nov 14, 2004 (gmt 0)

10+ Year Member



I use a little javascript bookmarklet.

Create a bookmark (favorite) and use the following as the location:


javascript:(function(){var mode=document.compatMode,m;if(mode){if(mode=='BackCompat')m='Quirks';else if(mode=='CSS1Compat')m='Standards Compliance';else m='';alert('The document is being rendered in '+m+' Mode.');}})();

When the page is displayed just click on the bookmark (favorite) and a js alert box will pop up with the browser mode.
6:09 pm on Nov 16, 2004 (gmt 0)

10+ Year Member



Remember that the user who comes to your site with IE 5.x is seeing everything in quirks, no matter what doctype you've got.

document.compatMode will give an "object not found" error in IE5.x

Ain't simple.

10:28 pm on Nov 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Wow, Saltminer, that's very neat. Thanks!
4:34 am on Nov 17, 2004 (gmt 0)

WebmasterWorld Senior Member jab_creations is a WebmasterWorld Top Contributor of All Time 10+ Year Member



This would be easier...


<a href="javascript:(function(){var mode=document.compatMode,m;if(mode){if(mode=='BackCompat')m='Quirks';else if(mode=='CSS1Compat')m='Standards Compliance';else m='';alert('The document is being rendered in '+m+' Mode.');}})();">IE Mode</a>

... and yes very cool. I hope IE will travel the same path as Netscape 4.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month