Pergunta

The w3C validator was all fine with this code:

<meta property="og:site_name" content="--Sitename--" />

If I replace the property attribute with name, the validator says og:site_name is not registered.

All of a sudden today it displayed this error:

Error Line 7, Column 66: Element meta is missing required attribute name.

Nothing is changed but this error popped up.

Anyone knows why, and the solution for that?

Foi útil?

Solução

For HTML5

If a meta element has the property attribute (from RDFa), the name attribute is not required.

See the section "Extensions to the HTML5 Syntax" from the W3C Recommendation HTML+RDFa 1.1 - Second Edition:

If the RDFa @property attribute is present on the meta element, neither the @name, @http-equiv, nor @charset attributes are required and the @content attribute MUST be specified.

So your markup is fine:

<meta property="og:site_name" content="--Sitename--" />

But it’s (now) even valid if you use the name attribute instead of RDFa’s property, because the OGP values are registered. So this is fine, too:

<meta name="og:site_name" content="--Sitename--" />

And you could even combine both ways:

<meta name="og:site_name" property="og:site_name" content="--Sitename--" />

Outras dicas

It's hard to get what validator and in what mode you're using. Suppose it's validator.w3.org. Than notice that HTML5 support there is "experimental". And "property" tags refer to rdfa which is part of HTML5 standard. To dive in further details one need your code snippet or page url...

I had the same problem which I find really borring.

This might not be the answer you were waiting for but I recommend using http://validator.nu/ instead of W3C validator.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top