Prevalence of ill-formed XHTML (was: Re: let authors choose text/html or application/xhtml+xml)

Robert Burns wrote:
> On Aug 31, 2007, at 7:50 AM, Dean Edridge wrote:
>> How much longer do we need to go on pretending that XHTML can be sent 
>> as text/html Dan? This is ridiculous. Hasn't the W3C learnt it's 
>> lesson with XHTML's failure over the last 8 years.
>> Exactly who benefits from the myth of XHTML being able to be sent as 
>> text/html? Not you, me, the W3c or anyone, and certainly not XHTML it 
>> self.
> I"m not sure why you call it a myth. I'm sure we can find countless 
> sites that serve valid XHTML files as text/html. This discussion keeps 
> popping up, but so far no one has been able to articulate what the 
> dangers are in doing so.

There's a bigger countless number that serve invalid XHTML files as 
text/html, and they are often invalid (in part) directly because of 
confusion between XML syntax and HTML syntax. I believe that that 
confusion is a real danger: XHTML-as-text/html has harder syntax than 
HTML, since you have to understand XML as well as 
HTML-as-misunderstood-by-browsers, so people get it wrong more often; 
and encouraging people to use the harder syntax will result in more 
errors and less happiness among those who follow the advice. (I think 
this encouragement issue is independent of DanC's proposal to permit the 
(discouraged) practice, though.)

Of the top 200 sites in Alexa's list (which I assume means there is a 
strong bias towards professionally-designed sites), looking at the front 
page of each (which I assume is more likely to have been checked with a 
validator than other less-prominent pages): 67 looked like they were 
using XHTML (they contained "DTD XHTML 1." somewhere); 51 were 
ill-formed XML (or, specifically, causing parse errors in libxml).

I looked in more detail at the first half, grouping by the first 
reported error - see below for the list. Unencoded ampersands in 
non-<script> contexts are errors in HTML too, but I think most of the 
other issues are fine in HTML, and it looks like many are caused by 
attempting to use HTML syntax in the XHTML document.

Of the pages without parse errors, most were valid - the only exceptions 
were (duplicate ID value) and sort of (sends invalid HTML4 to the validator, but sends 
valid XHTML1 to me - is that location-based?). (I have no idea how many 
would actually work as application/xhtml+xml, given the differences in 
the DOM and document.write and everything else.)

The lack of pages which are well-formed but invalid may suggest that few 
people are actually interested in well-formedness - some are just 
interested in validity, and fix their well-formedness errors as an 
incidental detail. Those people would get the same benefit from using 
HTML and an HTML validator instead.

Unencoded ampersands:
* if(op!=0) = 
* <a 
* <a 
* <embed 
quality="high" width="400" height="100" allowScriptAccess="always" 
* ...{"name":"World & 
* if (array != null && array.length > 0)
* <script language="javascript" 
Env={method:"GET",dev:0,start:(new Date( 
* <a 

Other unencoded characters:
* for (var i = 0; i < site_k.length; i++) {
* for(var i = 0; i < productName.length && random 
 > temp; i++) {
* document.write('<scr' + 'ipt src="' + adserver + 
allAdTags + ad1 + ad2 + ad3 + '?" type="text/javascript">'); 
document.write('</scr' + 'ipt>');
* document.write("<img style=\"display:none;\" 
width=1 height=1 

Unclosed tags:
* <img 
* <meta name="stencil" content="PGLS000022">
* <img src="/images/creative_user_logo.gif">
* <link rel="alternate" type="application/rss+xml" 
title="AOL Top Stories" 
* <link 
href="" type=image/x-icon 
rel="shortcut icon">
* <input name="f" value="D9_5_1" type="hidden">
* <meta http-equiv="Content-Type" 
content="text/html; charset=gb2312">

Other errors:
* <![if ! lt IE 5.5]>
* <html xmlns:web 
xmlns="" lang="en" xml:lang="en" 
class="liveApp la_en lo_gb">
* <meta  name=keywords content="..." />

Philip Taylor

Received on Friday, 31 August 2007 20:06:27 UTC