【发布时间】:2014-01-08 21:58:41
【问题描述】:
我正在开发一个个人网站,第一部分必须包含作者详细信息(例如他工作的组织和电子邮件)。我正在尝试为搜索引擎爬虫设置内容。
我正在使用 HTML 5 和微数据。下面是代码:
<header>
<address itemscope itemtype="http://schema.org/Person">
<h1 lang="pt" itemprop="name">Lorem Ipsum Dolor Sit Amet</h1>
<img itemprop="image" src="http://lorempixel.com/150/200/" lang="pt" alt="Lorem Ipsum Dolor Sit Amet">
<p itemprop="jobTitle">Professor of ...</p>
<div itemprop="worksFor" itemscope itemtype="http://schema.org/Organization">
<span itemprop="department" itemscope itemtype="http://schema.org/Organization"><span lang="pt" itemprop="name">Departamento de ...</span></span><br>
<span itemprop="name" lang="pt">Faculdade de Engenharia ...</span><br>
<div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
<span itemprop="streetAddress">Rua Dr. Roberto ...</span>, <span itemprop="postalCode">4200-465</span> <span itemprop="addressLocality">Porto, Portugal</span>
</div>
</div>
<p>Email: <a itemprop="email" href="mailto:foo@bar.com">foo@bar.com</a></p>
</address>
</header>
使用 W3C 验证器,我收到错误:
Line 11, Column 38: The element h1 must not appear as a descendant of the address element.
<h1 lang="pt" itemprop="name">Lorem Ipsum Dolor Sit Amet</h1>
我理解错误。我用的是h1,因为作者的名字也是网站的名字。
我的问题是你将如何解决这个问题?
【问题讨论】:
-
....将它移到 上方?
-
@Diodeus 会破坏语义。
-
@Diodeus 它与 schema.org 的东西没有任何关系; HTML 规范说明了哪些元素可以出现在其他元素中。
-
请注意,HTML5(仍在不断变化)提到 the address element 表示“地址元素表示其最近的文章或正文元素祖先的联系信息。如果那是正文元素,那么联系信息适用于整个文件。”标题出现在这样的元素中是没有意义的。
-
很多东西出现在多个地方,但这并不意味着它们是同一个东西。我不会将信件发送到文件的标题,而是将其发送到通信地址。它们是不同的东西,即使它们碰巧共享一些文本。如果其他人成为文档的维护者,那么他们的名字应该列在地址中,即使文档的标题保持不变。标题和联系人在语义上是不同的东西。如果您不想显示其中之一,那就是 CSS 的问题。
标签: html seo semantic-web semantic-markup microdata