views:

336

answers:

3

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!

A: 
<meta charset="UTF-8">

Try using this instead:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
WebDevHobo
I've already tried that. It does cause the "No Character encoding declared at document level" warning to go away, but otherwise doesn't fix anything.
Grant Heaslip
+1  A: 

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

Jeroen
+3  A: 

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

hsivonen