designer wrote:
Forgive my labouring the point, but after our discussions I have done what Gunlaug did, i.e., made a page as xhtml, with the headers as below:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html lang="en"
     xml:lang="en"
     xmlns="http://www.w3.org/1999/xhtml";>
<head>
<title>The Area</title>
<meta http-equiv="Content-Type"
       content="application/xhtml+xml; charset=utf-8" />

Changing the MIME type in the meta element is completely useless, as the application needs to know the MIME type in order to know how to parse it *before* it begins parsing. Once it has reached that meta element, parsing has already begun. It is the MIME type sent by the server in the HTTP Content-Type header that matters, and for your page it sends text/html.

See the HTTP headers:
http://cgi.w3.org/cgi-bin/headers?url=http%3A%2F%2Fwww.rhh.myzen.co.uk%2Frhh%2Fthearea%2Farea.php

You may see what happens when the page is really served as application/xhtml+xml.
http://software.hixie.ch/utilities/cgi/content-type-proxy/content-type-proxy?uri=http%3A%2F%2Fwww.rhh.myzen.co.uk%2Frhh%2Fthearea%2Farea.php&type=application%2Fxhtml%2Bxml

Note: The reason the stylesheet isn't applied at all in this case has nothing to do with it being served as XML, it's only because it's linked with a relative URI and via that proxy, it no longer points to the right place. If you change all paths to absolute URIs pointing to your server and the result will be better. It does, however, demonstrate that your page is at least well-formed.

I saved as xhtml and IE went daft. I saved as html and all seemed fine. However, the site I'm working on has a fair bit of PHP in it, so I saved it as .php. All seems fine, including IE.

Because it's php, you can use the header() function to send the correct Content-Type header. Place this before any content is output.

header("Content-Type: application/xhtml+xml");

However, doing so will lock out any IE users and Google, but you may as well completely remove the meta element, because it's only an inferior substitute for real HTTP headers. Use this instead:

header("Content-Type: text/html; charset=UTF-8");

If you choose to do content negotiation and serve application/xhtml+xml to browsers that support it and text/html to those that don't, be aware that it prevents incremental rendering in Mozilla.

You can see my test page at:

http://www.rhh.myzen.co.uk/rhh/thearea/area.php

So, my seemingly silly question is: Is this OK? Does it fall apart for anybody? (mac esp?)

and, of course, is it OK to do this, and indeed, is this what I 'should' be doing (Lachlan?)

You may as well just use valid HTML 4.01 Strict. See "XHTML is not for Beginners", the MIME type issue is just one of the many reasons.

http://lachy.id.au/log/2005/12/xhtml-beginners

(yes, I'm aware of the irony that the article itself is XHTML as text/html, but that's the useless default wordpress template that I'm too lazy to fix up)

Lastly, with regard to the style element within the page:
<style type="text/css">
/*<![CDATA[*/
<!--
@import url("../css/areastyle.css");
-->
/*]]>*/
</style>

You may as well remove the fake XML comment (<!-- and -->) in there, it's effectively useless these days, although keeping it as is will do no harm because of the CDATA section.

Keep the /*<![CDATA[*/ and /*]]>*/ in there, they're the most effective way to handle the different parsing requirements of HTML and XHTML. See this article that discusses the issue in great detail:

http://lachy.id.au/log/2005/05/script-comments

--
Lachlan Hunt
http://lachy.id.au/

******************************************************
The discussion list for  http://webstandardsgroup.org/

See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list & getting help
******************************************************

Reply via email to