W3C home > Mailing lists > Public > www-validator@w3.org > March 2008

Re: Whats wrong with W3C Validator?

From: Jukka K. Korpela <jkorpela@cs.tut.fi>
Date: Thu, 20 Mar 2008 15:25:44 +0200
Message-ID: <01dc01c88a8d$eb9b8980$0400000a@DOCENDO>
To: <www-validator@w3.org>
Cc: "Otto" <w3c@lmen.net>

Robin Daugherty wrote:

> The doctype declaration must be at the top of the document, and can
> only be preceded by whitespace to be valid.

That's not quite correct.

A doctype declaration can be preceded by a processing instruction, and 
<?php ... ?> would be such an instruction if it appeared at the start of 
a document. It would simply be ignored by a validator (and a browser). 
Normally it never reaches a validator (or a browser), since the PHP 
software, running on a server, reads the file and processes it before 
sending it in response to a request, and the processing includes the 
removal of <?php ...>.

If you try to validate a page by file upload or by direct input, with 
<?php ...> appearing at the start of the file, then the validator gets 
that line and not the processed data. The <?php ...> declaration does 
not make the document invalid, but the lack of processing means that 
what the validator gets can be quite different from the real content (as 
seen in normal validation by URL and as seen by browsers, search 
engines, etc.). So just don't do that. PHP-based pages must be validated 
using validation by URL. This means that you need to upload them before 
validation, but if this bothers you, you can upload them under some test 
name, validate, and only then rename them so that they have the intended 

A doctype declaration can also be preceded by a comment declaration, 
<!-- something -->. Such usage is not recommendable in general in HTML 
documents, since it throws IE into "Quirks Mode" (see 
http://www.cs.tut.fi/~jkorpela/quirks-mode.htm ), but note that a 
validator does not and must not report such a document as invalid. 
Starting with a comment is valid, though not good practice. (I guess a 
validator _could_ issue a _warning_, but this might be confusing to 
people who use the validator to check markup in situations where IE 
oddities don't matter and that may have nothing to do with HTML.)

Jukka K. Korpela ("Yucca")
Received on Thursday, 20 March 2008 13:26:28 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:59:06 UTC