Search code examples
metaw3c-validationfacebook-opengraphrdfa

W3C validator shows new error: "Meta requires 'name' attribute"


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?


Solution

  • 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--" />