3
votes

I'm trying to get a site to validate as HTML5 on the W3C Markup Validator. When I use the "Validate by URI" option, it generates a ton of errors, but when I copy and paste the HTML into the "Validate by direct input", it validates perfectly. When I run a diff on the two sources returned by the validator, the only differences are the Rails authenticity tokens (random strings Rails uses to validate forms - this is expected).

I've noticed that under both circumstances, I get a "No Character encoding declared at document level" warning, which I've seen on other sites but always assumed was a bug in the HTML5 validator, as I have an appropriate meta tag:

<meta charset="UTF-8">

Most of the errors are something along the lines of the following:

  • Quote " in attribute name. Probable cause: Matching quote missing somewhere earlier.
  • Bad value for attribute for on element label: An ID must not be the empty string.
  • Attribute "password" not allowed on element label at this point.

It acts like there's a mismatched quote, but I can't find anything wrong, and again, the identical direct input validates perfectly.

Any clue what's going on here? Thanks!

4
What Content-Type is being sent by the server? Does it include a charset and, if so, is it UTF-8? - Nate
I'm pretty inexperienced with HTTP headers, but I just checked using the Live HTTP Headers Firefox add-on and don't see any content-type parameters. Could this be causing the problem? Shouldn't it just fall back to the header in the document? - Grant Heaslip
@WebDevHobo: Screenshot of the HTTP headers or W3C results? - Grant Heaslip
I was going to say W3C result, but why not toss the headers in as well if you know how to get them(I sure don't) - KdgDev
I suspect that all of the errors are being caused by the Content-Type problem (especially since the markup validates perfectly when pasted into the validator). I'll check in later with the solution/more details. Thanks! - Grant Heaslip

4 Answers

4
votes

This is a known bug in the W3C Perl layer. Validator.nu has the same back end but without the Perl layer.

1
votes

It might be a validator bug, in which case your page could be of interest to the validator developers. Please consider getting in contact with them: http://validator.w3.org/feedback.html

0
votes
<meta charset="UTF-8">

Try using this instead:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
0
votes

Try <meta charset="UTF-8" /> including the closing forward slash