hsz
hsz

Reputation: 152216

IE6 changes DOCTYPE to a bad one

I am working with website that has defined following DOCTYPE:

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

When I access that website in IE6, DOCTYPE is magically changed to:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">

And.. Ok - it can stay because everything looks fine.. But here is the point - just one page has DOCTYPE changed to:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

which I can't stand.

What is the reason of changing XHTML to HTML 4.01 and HTML 4.0 ?

How can I force DOCTYPE in IE6 to XHTML or just HTML 4.01 ?

Upvotes: 2

Views: 431

Answers (3)

hsz
hsz

Reputation: 152216

The reason was unexpected:

HTML comment placed before <html> tag causes auto change of the page's doctype.

Upvotes: 1

Spudley
Spudley

Reputation: 168685

The only important thing that the doctype does is to force the browser into standards compliance mode. If you don't have a doctype, older browsers will go into Quirks mode; with the doctype (no matter which one you use), the browser will go into Standards mode.

Therefore it really doesn't matter which one you use.

The XHTML doctypes will try to enforce XHTML compliance, but obviously only in browsers that properly support XHTML - IE6 may be problematic here. And of course, specifying XHTML means there's no room for any errors at all, or your page won't be rendered.

Other than that, there's really not much to choose between the various doctypes, so my suggestion is to go with the most up-to-date one possible.... which is the HTML5 doctype.

The HTML5 doctype looks like this:

<!DOCTYPE html>

That's all. Short, simple and to the point. And it does the job for all current browsers (including IE6).

This doesn't mean you have to use any HTML5 features (they obviously won't work IE6 anyway), but it's fully backward compatible, and shouldn't give you any of the weird browser-specific glitches you get with other doctypes.

Hope that helps.

Upvotes: 0

Brendan
Brendan

Reputation: 37232

A browser only displays pages, and never modifies the original page.

The only way your question makes sense is if you're doing "save page as" and wondering why the page that IE saved isn't the same as the page it downloaded. In this case I'd expect the browser converts the page into a some sort of internal representation to make it easier to process, and "save page as" converts that internal representation back into HTML; so that it can save a single file (e.g. with embedded CSS rather than a separate CSS file), ensure that the saved file has correct markup (rather than the original potentially un-corrected markup), etc.

If this isn't what you want, go to "view -> page source" and copy & paste that instead.

Upvotes: 0

Related Questions