与<meta />结合使用时,微观数据项反射技术的W3C验证

时间:2014-08-21 16:08:18

标签: html w3c-validation microdata

考虑这个HTML:

<header>
    <div id="logo" itemscope itemtype="http://schema.org/Organization">
        <a itemprop="url" href="//www.seashellswebsite.co.uk/">
            <img itemprop="logo" src="logo.gif" alt="Seaside Shells" title="Seaside Shells">
        </a>
        <meta itemprop="name" content="Seaside Shells">
        <meta itemprop="legalName" content="Seaside Shells Ltd">
        <meta itemscope itemprop="address" itemtype="http://schema.org/PostalAddress" itemref="schemaOrganizationAddress">
        <meta itemprop="description" content="We sell sea shells on the sea shore. The sea shells we sell are unfortunately rather overpriced.">
    </div>
</header>

<h1>Super Interesting Page</h1>
<p>Foo bar.</p>

<footer>
    <span id="schemaOrganizationAddress">
        <span itemprop="streetAddress">1 Seafront Road</span>,
        <span itemprop="addressLocality">Fishing Town</span>,
        <span itemprop="addressRegion">Coastal County</span>,
        <span itemprop="postalCode">12345</span>
    </span>
</footer>

W3C Validator因此抱怨:

  

元素meta缺少必需的属性content

...并参考这一行:

<meta itemscope itemprop="address" itemtype="http://schema.org/PostalAddress" itemref="schemaOrganizationAddress">

但是content属性应该在什么位置,假设itemref属性表明内容位于当前范围之外的另一个元素中?在这种情况下,content属性肯定是需求过剩的吗?

1 个答案:

答案 0 :(得分:2)

您可以通过删除该元数据并将itemprop="address"放入页脚来修复它。

然后,您可以从itemtype="http://schema.org/Organization"

行引用页脚中的容器

您的代码中的微数据有效。它通过了Google's richsnippet validator

<header>
    <div id="logo" itemscope itemtype="http://schema.org/Organization" itemref="schemaOrganizationAddress">
        <a itemprop="url" href="//www.example.com/">
            <img itemprop="logo" src="logo.gif" alt="Seaside Shells" title="Seaside Shells">
        </a>
        <meta itemprop="name" content="Seaside Shells">
        <meta itemprop="legalName" content="Seaside Shells Ltd">
        <meta itemprop="description" content="We sell sea shells on the sea shore. The sea shells we sell are unfortunately rather overpriced.">
    </div>
</header>

<h1>Super Interesting Page</h1>
<p>Foo bar.</p>

<footer>
    <span id="schemaOrganizationAddress" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
        <span itemprop="streetAddress">1 Seafront Road</span>,
        <span itemprop="addressLocality">Fishing Town</span>,
        <span itemprop="addressRegion">Coastal County</span>,
        <span itemprop="postalCode">12345</span>
    </span>
</footer>