问题
When validating my page, the W3-Validator gives me an error for every
<tag addthis:title="AddThis share title" />
attribute in my code. How can I make those attributes valid for HTML5, so the page validates? I need those tags so addthis uses the correct titles for my sharing links, so I can't get rid of them...
回答1:
You can't make them valid. Not in HTML, not in XHTML. The only valid custom attributes allowed in HTML5 start "data-".
You could make your markup valid HTML5+something or XHTML5+something, but getting a validator to check for that is a non-trivial task.
回答2:
I'd have to assume that "addthis" is an XML namespace; does the html tag declare something like <html xmlns:addthis="..">
? If not, it won't validate because the namespace is undefined for the document. If so, it won't validate because "addthis" isn't a standard namespace.
See: http://www.w3.org/TR/2011/WD-html5-20110405/namespaces.html
Confounded to your troubles is the fact that "the HTML syntax does not support namespace declarations, even in foreign elements."
Check out http://www.w3.org/TR/2011/WD-html5-20110405/syntax.html#elements-0 , the cdr:license
example.
Unfortunately (in your case) HTML5 isn't XML, so XML namespaces aren't necessarily valid in HTML5. Your only real option is to ignore the validation error.
Not unrelated question: HTML5 validator failing on Facebook OpenGraph XML Namespace xmlns:og
Oh, and while you're there, the <tag />
syntax is also XML, not HTML5.
来源:https://stackoverflow.com/questions/10245807/html5-valid-namespace-tag-prefixes