问题描述:

I'm trying to validate the website http://www.athometechsolutions.net/index.php and I'm having trouble.

When I type the URL into the W3 validation service, I get the following error:

Error Line 12, Column 1: character data is not allowed here

<meta http-equiv="content-type" content="text/html; charset=UTF-8" />

You have used character data somewhere it is not permitted to appear. Mistakes that can cause this error include:

putting text directly in the body of the document without wrapping it in a container element (such as a <p>aragraph</p>), or

forgetting to quote an attribute value (where characters such as "%" and "/" are common, but cannot appear without surrounding quotes), or

using XHTML-style self-closing tags (such as <meta ... />) in HTML 4.01 or earlier. To fix, remove the extra slash ('/') character. For more information about the reasons for this, see Empty elements in SGML, HTML, XML, and XHTML.

However, I can't see anything wrong with the code. And, what makes it even more puzzling, is that when I copy and paste the "view-source" code into the W3 validation service, it PASSES.

I'd really like for it to pass on it's own, and I can't figure out why it won't.

It seems to me it has something to do with the first php include in the head of the document, because the error message location changes when I move pieces out of the include and into the regular header. However, it seems to me that it should load just fine (from PHP - Is it dumb to load <head></head> data as an include and other documents).

So, I ask, how can I get it to validate through the URL?

Thanks!

网友答案:

Looking at the source code of your page in the HEX editor view in Notepad++ reveals that you have a Byte Order Mark there before the meta element the validator mentions.

Since a Byte Order Mark is not displayed by most editors, this is quite hard to spot.

And, what makes it even more puzzling, is that when I copy and paste the "view-source" code into the W3 validation service, it PASSES.

Since a Byte Order Mark only makes sense at the beginning of a document, most likely your editor (or another component in the chain) removes it silently when you copy&paste it to the validator.

相关阅读:
Top