homepage Welcome to WebmasterWorld Guest from 174.129.130.202
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
Why does IE not like doctypes?
JAB Creations




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

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.

 

klogger




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

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

stever




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

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

The declarations send IE into quirks mode.

JAB Creations




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

IT WORKS! IE is able to render the page correctly and W3 reads it as a valid page. SCHWEET! Thanks! :-)

encyclo




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

<?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.

klogger




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

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!

Lance




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

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

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

Saltminer




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

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.

JAB Creations




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

Umm, how can you tell when IE is in quirks or standards mode?

klogger




msg:584341
 2:20 pm on Nov 14, 2004 (gmt 0)

Thanks Saltminer - clears up some things for me.

Saltminer




msg:584342
 2:46 pm on Nov 14, 2004 (gmt 0)

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.

ricfink




msg:584343
 6:09 pm on Nov 16, 2004 (gmt 0)

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.

Purple Martin




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

Wow, Saltminer, that's very neat. Thanks!

JAB Creations




msg:584345
 4:34 am on Nov 17, 2004 (gmt 0)

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved