<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: Problems with XHTML content type.</title>
	<link>http://ask.metafilter.com/63715/Problems-with-XHTML-content-type/</link>
	<description>Comments on Ask MetaFilter post Problems with XHTML content type.</description>
	<pubDate>Wed, 30 May 2007 14:13:39 -0800</pubDate>
	<lastBuildDate>Wed, 30 May 2007 14:13:39 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: Problems with XHTML content type.</title>
		<link>http://ask.metafilter.com/63715/Problems-with-XHTML-content-type</link>	
		<description>I seem to have hit a bit of a brick wall in approximating  W3C XHTML standards compliance on my website. From what I&apos;ve read, XHTML &lt;em&gt;should&lt;/em&gt; be served with content type &lt;strong&gt;application/xhtml+xml&lt;/strong&gt;, rather than &lt;strong&gt;text/html&lt;/strong&gt;, and recent versions of Microsoft and Mozilla browsers should support serving them as such. Well, they aren&apos;t. &lt;br /&gt;&lt;br /&gt; I set the content type and character set for all of my pages using the &lt;em&gt;header&lt;/em&gt; statement in my primary include file, as shown &lt;a href=&quot;http://www.confessor.org/sourcecode.php?id=6#l19&quot;&gt;here&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
When I try to switch the content type (currently by commenting one line and uncommenting the other), however, the following happens:&lt;br&gt;
&lt;br&gt;
Firefox 2.0.0.3 complains that &lt;em&gt;this XML file does not appear to have any style information associated with it&lt;/em&gt;, and displays a bare document trees.&lt;br&gt;
&lt;br&gt;
Internet Explorer 7.0.5450.4 opens an Open/Save/Cancel for a file of type php_auto_file.&lt;br&gt;
&lt;br&gt;
Opera for Wii shows the bare interface, stripped of all styling.&lt;br&gt;
&lt;br&gt;
Can anybody help me figure out what&apos;s going wrong?</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2007:site.63715</guid>
		<pubDate>Wed, 30 May 2007 14:04:08 -0800</pubDate>
		<dc:creator>The Confessor</dc:creator>
		
			<category>XHTML</category>
		
			<category>standards</category>
		
			<category>W3C</category>
		
	</item> <item>
		<title>By: simonw</title>
		<link>http://ask.metafilter.com/63715/Problems-with-XHTML-content-type#958616</link>	
		<description>The first question you should be asking is why you need XHTML - if you don&apos;t have a specific reason (the need for XML parsers to be able to consume your pages) you&apos;re much better off with HTML 4.01 for now, and HTML 5 in probably a year or so.&lt;br&gt;
&lt;br&gt;
As for serving up XHTML, you need to check the browser&apos;s HTTP_ACCEPT header to decide whether or not to serve it (IE, including IE 7, can&apos;t handle it at all and will offer to download it).&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt; ?phpbr&gt;
if ( stristr($_SERVER[&quot;HTTP_ACCEPT&quot;],&quot;application/xhtml+xml&quot;) ) {&lt;br&gt;
  header(&quot;Content-type: application/xhtml+xml&quot;);&lt;br&gt;
}&lt;br&gt;
else {&lt;br&gt;
  header(&quot;Content-type: text/html&quot;);&lt;br&gt;
}&lt;br&gt;
?&amp;gt;&lt;/&gt;&lt;/pre&gt;Be warned: there are a TON of gotchas involved in serving using the application/xhtml+xml content type, especially relating to JavaScript. &lt;a href=&quot;http://www.xml.com/pub/a/2003/03/19/dive-into-xml.html&quot;&gt;This article&lt;/a&gt; from 2003 is still very relevant.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.63715-958616</guid>
		<pubDate>Wed, 30 May 2007 14:13:39 -0800</pubDate>
		<dc:creator>simonw</dc:creator>
	</item><item>
		<title>By: Khalad</title>
		<link>http://ask.metafilter.com/63715/Problems-with-XHTML-content-type#958621</link>	
		<description>I use this PHP code on my &lt;a href=&quot;http://www.progeny.net/&quot;&gt;company&apos;s web site&lt;/a&gt;:&lt;br&gt;
&lt;blockquote&gt;&lt;code&gt;if (preg_match(&apos;{\bapplication/xhtml\+xml\b[^;]*;q=(1.0|0.[1-9])}&apos;, $_SERVER[&apos;HTTP_ACCEPT&apos;]))&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;header(&apos;Content-Type: application/xhtml+xml; charset=UTF-8&apos;);&lt;br&gt;
else&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;header(&apos;Content-Type: text/html; charset=UTF-8&apos;);&lt;/code&gt;&lt;/blockquote&gt;It ends up serving application/xhtml+xml to Firefox and text/html to Internet Explorer. I&apos;m not sure if IE7 supports application/xhtml+xml, but IE6 definitely doesn&apos;t.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.63715-958621</guid>
		<pubDate>Wed, 30 May 2007 14:15:46 -0800</pubDate>
		<dc:creator>Khalad</dc:creator>
	</item><item>
		<title>By: deern the headlice</title>
		<link>http://ask.metafilter.com/63715/Problems-with-XHTML-content-type#958661</link>	
		<description>&lt;em&gt;The first question you should be asking is why you need XHTML - if you don&apos;t have a specific reason (the need for XML parsers to be able to consume your pages) you&apos;re much better off with HTML 4.01&lt;/em&gt;&lt;br&gt;
&lt;br&gt;
Seconded.&lt;br&gt;
&lt;br&gt;
If you want to read a very comprehensive &amp;amp; informative take on the issue, &lt;a href=&quot;http://www.sitepoint.com/forums/showthread.php?t=393445&quot;&gt;check out Tommy Olson&apos;s article&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
Also: &lt;em&gt;&lt;a href=&quot;http://www.hixie.ch/advocacy/xhtml&quot;&gt;Sending XHTML as text/html Considered Harmful&lt;/a&gt;&lt;/em&gt;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.63715-958661</guid>
		<pubDate>Wed, 30 May 2007 14:46:42 -0800</pubDate>
		<dc:creator>deern the headlice</dc:creator>
	</item><item>
		<title>By: simonw</title>
		<link>http://ask.metafilter.com/63715/Problems-with-XHTML-content-type#958688</link>	
		<description>Forgot to mention: the best reason to use XHTML is if you want to embed SVG or MathML in your pages. Again, that trick won&apos;t work in any existing version of Internet Explorer.&lt;br&gt;
&lt;br&gt;
Generally though it&apos;s best avoided. I served my personal site in XHTML with the correct content type for several years; it was a nuisance. The XML error model is fundamentally unsuited to the Web.&lt;br&gt;
&lt;br&gt;
One of the reasons HTML 5 is so interesting is that it attempts to specify an error model that is as close as possible to the way actual browsers work today.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.63715-958688</guid>
		<pubDate>Wed, 30 May 2007 15:07:16 -0800</pubDate>
		<dc:creator>simonw</dc:creator>
	</item><item>
		<title>By: The Confessor</title>
		<link>http://ask.metafilter.com/63715/Problems-with-XHTML-content-type#958705</link>	
		<description>Figured out my problem using &lt;strong&gt;deern the headlice&lt;/strong&gt;&apos;s link to Tommy Olson&apos;s article. T&apos;was missing the xmlns attribute in my html tag.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.63715-958705</guid>
		<pubDate>Wed, 30 May 2007 15:23:20 -0800</pubDate>
		<dc:creator>The Confessor</dc:creator>
	</item><item>
		<title>By: The Confessor</title>
		<link>http://ask.metafilter.com/63715/Problems-with-XHTML-content-type#958840</link>	
		<description>And not only does it bork IE, it also completely kills Google Maps API in every browser! So I guess I&apos;ll abandon that content type declaration at least until Google decides to support it...&lt;br&gt;
&lt;br&gt;
I&apos;m still grateful for the assistance, though, as I was able to check the XML well-formedness of markup that I would have never taken the time to expose to an actual validation service.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.63715-958840</guid>
		<pubDate>Wed, 30 May 2007 17:29:15 -0800</pubDate>
		<dc:creator>The Confessor</dc:creator>
	</item><item>
		<title>By: Civil_Disobedient</title>
		<link>http://ask.metafilter.com/63715/Problems-with-XHTML-content-type#958891</link>	
		<description>Something to keep in mind when you make the switch back into &quot;html-thinking&quot; is that a lot of tags aren&apos;t supposed to be closed.  For example, according to the W3C, &lt;a href=&quot;http://www.w3.org/TR/html401/struct/text.html#h-9.3.2.1&quot;&gt;end tags are &lt;i&gt;forbidden&lt;/i&gt; in line breaks (&amp;lt;br&amp;gt;)&lt;/a&gt;, as well as &lt;a href=&quot;http://www.w3.org/TR/html401/interact/forms.html#h-17.4&quot;&gt;&amp;lt;input&amp;gt; tags&lt;/a&gt;.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.63715-958891</guid>
		<pubDate>Wed, 30 May 2007 18:29:00 -0800</pubDate>
		<dc:creator>Civil_Disobedient</dc:creator>
	</item><item>
		<title>By: Khalad</title>
		<link>http://ask.metafilter.com/63715/Problems-with-XHTML-content-type#961073</link>	
		<description>&lt;small&gt;That just means you can&apos;t write &amp;lt;br&amp;gt;&amp;lt;/br&amp;gt; or &amp;lt;input&amp;gt;&amp;lt;/input&amp;gt;.&lt;/small&gt;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.63715-961073</guid>
		<pubDate>Fri, 01 Jun 2007 13:52:47 -0800</pubDate>
		<dc:creator>Khalad</dc:creator>
	</item><item>
		<title>By: Civil_Disobedient</title>
		<link>http://ask.metafilter.com/63715/Problems-with-XHTML-content-type#961094</link>	
		<description>No, it also means you can&apos;t write &lt;code&gt;&amp;lt;br /&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;input type=&quot;text&quot; value=&quot;Something&quot; /&amp;gt;&lt;/code&gt;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.63715-961094</guid>
		<pubDate>Fri, 01 Jun 2007 14:11:23 -0800</pubDate>
		<dc:creator>Civil_Disobedient</dc:creator>
	</item><item>
		<title>By: Civil_Disobedient</title>
		<link>http://ask.metafilter.com/63715/Problems-with-XHTML-content-type#961095</link>	
		<description>Or, for that matter, &lt;code&gt;&amp;lt;img src=&quot;something.jpg&quot; /&amp;gt;&lt;/code&gt;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.63715-961095</guid>
		<pubDate>Fri, 01 Jun 2007 14:12:00 -0800</pubDate>
		<dc:creator>Civil_Disobedient</dc:creator>
	</item><item>
		<title>By: Khalad</title>
		<link>http://ask.metafilter.com/63715/Problems-with-XHTML-content-type#961275</link>	
		<description>End &lt;em&gt;tags&lt;/em&gt; are forbidden. HTML 4.x is not aware at all of &quot;empty element syntax&quot;, which is what the slash is. In XHTML the slash at the end indicates an element element and is equivalent to an immediate end tag; the slash itself is not an end tag, however. In HTML 4.x the slash is bad syntax, but is valid because of the very precise rules the HTML specification lays out for handling parsing errors. Strictly speaking, the slash is actually supposed to be parsed as an invalid attribute by a proper HTML 4.x parser.&lt;br&gt;
&lt;br&gt;
The end result is that an XHTML parser will see an empty element and an HTML parser will see an malformed attribute. For always-empty elements like &amp;lt;link&amp;gt; and &amp;lt;br&amp;gt; and &amp;lt;input&amp;gt; that works great, and is a nice way to write XHTML that won&apos;t choke a plain HTML parser.&lt;br&gt;
&lt;br&gt;
&amp;lt;br /&amp;gt; might not validate as proper HTML, since &apos;/&apos; is not a valid attribute, but syntactically, it is just fine.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.63715-961275</guid>
		<pubDate>Fri, 01 Jun 2007 18:53:43 -0800</pubDate>
		<dc:creator>Khalad</dc:creator>
	</item><item>
		<title>By: Civil_Disobedient</title>
		<link>http://ask.metafilter.com/63715/Problems-with-XHTML-content-type#962667</link>	
		<description>Um, just because it works doesn&apos;t mean it&apos;s syntactically correct.  For example, when using XSLT to transform a document &lt;i&gt;into&lt;/i&gt; HTML, there is a property to define the output method (&lt;b&gt;&amp;lt;xsl:output method=&quot;html&quot;/&amp;gt;&lt;/b&gt;).  And what does it transform hard breaks into?  &lt;b&gt;No closing slash.&lt;/b&gt;  Why&apos;s that?  Because it&apos;s &lt;em&gt;wrong&lt;/em&gt;.&lt;br&gt;
&lt;br&gt;
Go try your end slash HTML in Navigator 3 and see what happens.  It&apos;ll break, that&apos;s what.  And why?  Because it&apos;s &lt;b&gt;wrong&lt;/b&gt;.  Just because self-closing tags &lt;i&gt;work&lt;/i&gt; in your modern, fancy-pants browser, does not make it &lt;i&gt;correct&lt;/i&gt;.&lt;br&gt;
&lt;br&gt;
The following tags are &lt;i&gt;not closed&lt;/i&gt; in valid HTML (this includes &lt;i&gt;self-closing&lt;/i&gt;): area, base, basefont, br, col, frame, hr, img, input, isindex, link, meta, param.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.63715-962667</guid>
		<pubDate>Sun, 03 Jun 2007 14:20:00 -0800</pubDate>
		<dc:creator>Civil_Disobedient</dc:creator>
	</item><item>
		<title>By: Khalad</title>
		<link>http://ask.metafilter.com/63715/Problems-with-XHTML-content-type#962909</link>	
		<description>Everything I said is according to the W3C&apos;s HTML 4 specification. &amp;lt;br /&amp;gt; is syntactically valid, and is equivalent to &amp;lt;br /=&quot;/&quot;&amp;gt;. Any conforming HTML 4 user agent, which Navigator 3 is not, &lt;em&gt;must&lt;/em&gt; handle &amp;lt;br /&amp;gt; properly.&lt;br&gt;
&lt;br&gt;
There&apos;s a distinction to be made between code that validates and code that is well-defined. The &lt;a href=&quot;http://www.webstandards.org/action/acid2/&quot;&gt;Acid2 Test&lt;/a&gt;, for instance, tests how browsers handle various constructs that are completely invalid HTML/CSS, but nevertheless must be handled in a well-defined manner by conforming HTML user agents.&lt;br&gt;
&lt;br&gt;
&lt;i&gt;The following tags are not closed in valid HTML (this includes self-closing): area, base, basefont, br, col, frame, hr, img, input, isindex, link, meta, param.&lt;/i&gt;&lt;br&gt;
&lt;br&gt;
The tags are not closed, but the elements are.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.63715-962909</guid>
		<pubDate>Sun, 03 Jun 2007 19:02:20 -0800</pubDate>
		<dc:creator>Khalad</dc:creator>
	</item>
	</channel>
</rss>
