Note that there are some explanatory texts on larger screens.

plurals
  1. PODoes PHP or Apache affect DTD: Problem with rendering XHTML in IE7 standard mode
    primarykey
    data
    text
    <p>I have a static HTML(index.html) with DOCTYPE below which will trigger the standard mode in IE7:</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt; &lt;head&gt; </code></pre> <p>I then transform the page into three PHP HTML templates:header.html.php, index.php, footer.html.php. And the header.html.php includes the exact DOCTYPE as above.</p> <p>But every time I claim the index.php in IE7, it messes up the rendering.</p> <p>I have used the command <code>javascript:alert(document.compatMode)</code> to test in IE7 and FF3</p> <p>For the static html page, both IE7 and FF3 give me CSS1Compat, which is the mode I expected; But for the PHP generated page, FF3 give me CSS1Compat while IE7 give me BackCompat.</p> <p><strong>Here is something I think the problem lies:</strong> I have downloaded the page from IE7 and found the DOCTYPE become <code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&gt;</code> without the address.</p> <p>But downloading the same PHP generated page in ff3 and chrome, the DOCTYPE is correctly <code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;</code></p> <p>When I test the page, not surprisingly, the very first lines the source code the W3C validator get is <code># &lt;!-- A customized tag to distinguish different pages --&gt; # &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;</code></p> <p>And a W3C validation indicates the empty first line.</p> <p>I have removed the BOM on <strong>all</strong> the static PHP files and CSS files but I still get the problem.</p> <p>Is this a problem with Apache or PHP? Anyone have a clue to fix this?</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COCould you post something from your header.html.php file so we can see if there is something near the beginning that's causing this fail? Also, what happens when you run the javascript for the php generated page in a webkit browser? The only reason that could be of interest is because FF3 and IE7 currently give you different results...
      singulars
    2. CO@jlmcdonald here is the full content of the header.html.php and the javascript result in chrome is the same as FF3. `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="en"> <head> <!-- Make IE8 works in IE7 standard mode --> <meta http-equiv="X-UA-Compatible" content="IE=7;FF=3;OtherUA=4" /> <title><?php echo "$title"; ?></title> <link rel="stylesheet" href="stylesheets/reset.css" /> <link rel="stylesheet" href="stylesheets/960.css" /> <link rel="stylesheet" href="stylesheets/style.css" /> </head> <body>`
      singulars
    3. COOne possibility could be that the php files have some hidden byte order marks that don't show up as whitespace or anything else ... but that BOM will throw IE7 into quirks mode. See this question which offers a solution. It may not be your problem, but it could help. http://stackoverflow.com/questions/5063789/why-is-the-site-running-in-ie-quirks-mode
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload