考虑这个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
属性肯定是需求过剩的吗?
答案 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>