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
    text
    copied!<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>
 

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