michaelreneer Posted September 20, 2007 Share Posted September 20, 2007 Ok, here it is. I have created a website with php. The pages generated by the php are standards compliant xml. As I navigate through my website everything is as should be, except for when randomly my styles go haywire. Now this phenomenon happens site-wide so not page specific and it happens at random intervals. Meaning that I can sit on the home page and hit refresh 30 times and a random 5 will be messed up. It happens in all the browsers that I have tested. It only happens when its online, when its on my local machine things are fine. After I generate a screwed up page I check the compatmode the browser and it yields that in fact the page was generated in backCompat or quirks mode. When the page displays as normal the browser shows the page was generated with css1compat or compatible. My hypothesis is that the php is parsing inconsistently and occasionally extra hex characters are being inserted into the beginning of the html. What I have read is that sometimes if there are comments or characters in front of the <?xml ... start of the page then the browser kicks it over to quirks mode. On the other hand I also remember reading that this only occurred in ie6. This problem only happens when the site is live and not when it is on my local machine, its intermittent, I am more then happy to give any more information just ask. I would love help. Michael Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 20, 2007 Share Posted September 20, 2007 your website should be standards compliant XHTML, not XML. If your website is XML, I can see why you're having problems. You don't need <?xml on your regular pages. Only on XML ones. Not XHTML. Quote Link to comment Share on other sites More sharing options...
michaelreneer Posted September 20, 2007 Author Share Posted September 20, 2007 <?xml version='1.0' encoding='utf-8'?> <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'> <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'> <head> is this not correct? Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 20, 2007 Share Posted September 20, 2007 Do a quick google on XML and XHTML. Unless I've gone temporarily insane, they are two different things, and you're using one wrong. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted September 20, 2007 Share Posted September 20, 2007 you are not insane, but correct as usual. Quote Link to comment Share on other sites More sharing options...
michaelreneer Posted September 20, 2007 Author Share Posted September 20, 2007 http://www.w3.org/QA/2002/04/valid-dtd-list.html has <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>An XHTML 1.0 Strict standard template</title> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <meta http-equiv="Content-Style-Type" content="text/css" /> </head> <body> <p>… Your HTML content here …</p> </body> </html> is this not correct? Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 20, 2007 Share Posted September 20, 2007 I never have that line on my xhtml pages and they validate perfectly. I don't see why you'd have an xml version on a page like that, but I don't use XML often. XHTML is like an extension of XML, but it's not the same thing. Quote Link to comment Share on other sites More sharing options...
michaelreneer Posted September 20, 2007 Author Share Posted September 20, 2007 only reason i had it there was because w3c told me to... lol... let me try taking it out and see what happens. thanks Michael Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 20, 2007 Share Posted September 20, 2007 Maybe this will help: http://en.wikipedia.org/wiki/XHTML XML Declaration A character encoding may be specified at the beginning of an XHTML document in the XML declaration when the document is served using the application/xhtml+xml MIME type. (If an XML document lacks encoding specification, an XML parser assumes that the encoding is UTF-8 or UTF-16, unless the encoding has already been determined by a higher protocol.) For example: <?xml version="1.0" encoding="UTF-8"?> The declaration may be optionally omitted because it declares as its encoding the default encoding. However, if the document instead makes use of XML 1.1 or another character encoding, a declaration is necessary. Internet Explorer prior to version 7 enters quirks mode if it encounters an XML declaration in a document served as text/html. Quote Link to comment Share on other sites More sharing options...
michaelreneer Posted September 20, 2007 Author Share Posted September 20, 2007 since removing the <?xml ... jazz i have not been able to duplicate the phenomenon. So I was encountering this issue because my files were probably saved as a different encoding then the xml parser of the browser? can anyone give me an example of when you would want to use the optional <?xml version="1.0" encoding="UTF-8"?> and when you would not want to ? Thanks Michael Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 20, 2007 Share Posted September 20, 2007 I would only use it if you needed to use a different version. Or, if you use PHP to set the content type as the correct type, and not text/html to prevent IE6- from freaking out. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.