2

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...

F.P
  • 17,421
  • 34
  • 123
  • 189

2 Answers2

4

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.

Community
  • 1
  • 1
Matty K
  • 3,781
  • 2
  • 22
  • 19
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.

Alohci
  • 78,296
  • 16
  • 112
  • 156
  • 1
    Actually, in XHTML they are valid, as long as you declare the namespace correctly to be a non-HTML namespace. The `tag` element, however, is not valid, it should be in another namespace. See http://www.w3.org/TR/xhtml1/#well-formed – Abel May 23 '13 at 07:10
  • @Abel - Please cite where in any HTML or XHTML spec it says they are valid. – Alohci May 23 '13 at 07:14
  • I already updated my comment while you were answering ;). In addition, in HTML5, two other namespaces are allowed, MathML and SVG. – Abel May 23 '13 at 07:15
  • Well-formed-ness is not validity. – Alohci May 23 '13 at 07:16
  • The way I read it (but I can be wrong of course) is that only "strict" conformance is hampered this way. – Abel May 23 '13 at 07:17
  • No, all versions of HTML require conformance to the content model. No version of HTML or XHTML has a content model, that permits arbitrary elements from any namespace. – Alohci May 23 '13 at 07:20
  • Quote: "The XHTML namespace may be used with other XML namespaces as per [XMLNS]". Because XHTML is based on XML+NS, this is valid and conforming. But, other quote: "such documents are not strictly conforming XHTML 1.0 documents as defined above", meaning they are not strict. However, unless you have a validator that knows the other namespaces, this cannot be validated (this applies to all XML+NS). I agree, however, that it is a little vague, as the DTD in the spec is normative and we all know that DTD's cannot be made to understand XML+NS. – Abel May 23 '13 at 07:28
  • Right, XHTML can be mixed with elements from other namespaces, But the resulting document is not XHTML. It's XHTML + something, which is what I say in my answer. – Alohci May 23 '13 at 07:31
  • Oh, I see. No, that's using "strictly" in a different way. It has nothing to do with "strict" vs "transitional" vs "frameset" – Alohci May 23 '13 at 07:38