Page is a not externally linkable
DrDoc - 2:10 am on Apr 3, 2006 (gmt 0)
First, let me preface my statement by saying that I am not completely anti-XHTML. As someone cleverly pointed out to me in a sticky, I use XHTML myself (I was wondering how long it would take for anyone to point that out). ;) What I am against, however, is uneducated and misinformed implementations of XHTML without fully understanding the implications. Way too often have I seen XHTML implementations which were so carelessly carried out as to completely missing the target. XHTML can, and perhaps should be, a viable alternative for public consumption if, and only if, it is implemented 100% correctly. What this means is that you should not use XHTML unless:
Let me just say something I was hoping to avoid having to say in the first place ...
The education can best be carried out in two ways: first, careful reading and pondering of Ian Hickson's article; second, careful reading and pondering of W3C's XHTML documentation. Read until you understand.
Once you have gained the needful knowledge about XHTML through the two aforementioned documents you can move to implement your newfound knowledge. Doing so requires more than mere markup. Reading between the lines in both Ian's article and W3C's documentation, one more change is necessary. You should ensure that your server does the following, whether directly in your server's settings, or through explicit header output through server side scripting.
To avoid throwing IE into quirksmode we really want to avoid including the XML prolog on our pages. In order to do so, the W3C documentation declares that character set must be specified by a "higher protocol". To you, that means it must be sent by the server. Again, this can be done directly in the server configuration, or by properly outputting the appropriate "content-type" header.
Now, in all honesty it should be said that sending XHTML as text/html is not going to cause severe problems in IE. But, doing so across the board is also not going to justify using XHTML over HTML 4.01, as "text/html" effectively nullifies use of XHTML to begin with, and removes any of the benefits for choosing XHTML in the first place. You therefore want to check whether the browser sends the
HTTP_ACCEPT header. If
HTTP_ACCEPT is being sent and contains application/xhtml+xml, use this content-type header: Content-Type: application/xhtml+xml;charset=ISO-8859-1 HTTP_ACCEPT is being sent, but does not contain application/xhtml+xml, use this content-type header: Content-Type: text/html;charset=ISO-8859-1 HTTP_ACCEPT is not being sent at all, use this content-type header: Content-Type: application/xhtml+xml;charset=ISO-8859-1 In PHP, that is accomplished as follows:
|
Adjust charset as appropriate. I put the content-style-type and content-script-type headers in there for good measure as well.
Now, by doing that you are not only sending XHTML according to the W3C recommendations, you are truly making your site both forward and backward compatible while doing what XHTML was designed to do -- taking the web one step closer to being able to fully utilize the power of XML.
If you are incapable of the above implementation, or simply lack the ability to do so, stick with HTML 4.01 as it is the better tool for the job at this point.