Search code examples
htmlxhtmldoctypequirks-mode

Doctype meta and quirksmode


Please can I clarify some thinking here:

Quirksmode is invoked if no doctype is specified.

but

When served from localhost IE appears to go into quirksmode regardless of doctype. Please can this be confirmed and can someone explain why this is the case.

however

When served from localhost and IE goes into quirksmode regardless of doctype this can be overridden by including a meta tag in the first line of the head

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

This doesn't work for me ... have I got the syntax wrong?

The meta in the head will only ever be applied when served from localhost? Is this true if so why.

At the moment everything looks fine in FF Chrome Opera etc whether served from localhost or across the net.

But I just get quirks mode in IE

My doctype is

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

Finally is there a relationship between charset and quirksmode?

I have been using

<meta http-equiv="content-type" content="text/html; charset=utf-8" />       

On apache with apache config set to default to UTF-8


Solution

  • I wanted to summarise the findings from this question.

    To switch off compatibility mode in IE9

    1. in IE 9 right click tools icon and select command bar
    2. from command bar select tools
    3. from tools select Compatibility View Settings
    4. uncheck display intranet site in compatibility mode
    5. from command bar select tools ensure compatibility view is unchecked
    6. Restart Browser

    Main points for changing code

    • The html 5 doctype simplifies the whole issue of setting a doctype.
    • The reason that there appeared to be a relationship between charset and quirksmode was the error in the meta to add that charset which put it in conflict with the doctype.

    So actions completed to resolve problem.

    1. Ignore localhost quirksmode - this is only significant when testing.
    2. Use <!Doctype html> ensuring that the html document commences with this. N:B this does not mean that this has to be the first line of the HTML. php includes can precede it.

    3. In the <head> Use <meta charset="UTF-8">

    4. In php initialize use <?php header("content-Type: text/html; charset=utf-8"); ?>