gpt4 book ai didi

html - 表格上的微数据

转载 作者:太空狗 更新时间:2023-10-29 14:15:54 36 4
gpt4 key购买 nike

我是 Microdata 的新手,对 table 中的 itemscope 有疑问。

例如,假设我有一个人对象,并且在表中显示了姓名、街道和城市列。

<table>
<tr itemscope itemtype="http://schema.org/Person">
<td itemprop="name">Name</td>
<td itemprop="streetAddress">123 main</td>
<td itemprop="addressCountry">USA</td>
</tr>
</table>

请注意,streetAddressaddressCountry 应该是 address 属性的子项。然而,您不能添加父 div 来对 table 中的那些进行分组。

此外,点符号似乎不起作用,例如地址.streetAddress

如何支持这一点?

最佳答案

对此只有相当丑陋的解决方案。

您可以为国家/地区使用 itemref 属性,但您必须添加一个虚拟的未类型化 itemscope 以便 addressCountry 属性不会添加到 Person 项:

<table>
<tr itemscope itemtype="http://schema.org/Person">
<td itemprop="name">
Name
</td>
<td itemprop="address" itemscope itemtype="http://schema.org/PostalAddress" itemref="country">
<span itemprop="streetAddress">123 main</span>
</td>
<td itemscope>
<span itemprop="addressCountry" id="country">USA</span>
</td>
</tr>
</table>

您几乎可以将 itemref 用于任何事情,这样您就不必添加虚拟 itemscope,但是标记会变得更加复杂,您必须“外包“Person 项目:

<meta itemscope itemtype="http://schema.org/Person" itemref="person-name person-address" />

<!-- can’t have this as descendant of another Microdata item -->

<table>
<tr>
<td itemprop="name" id="person-name">
Name
</td>
<td itemprop="address" itemscope itemtype="http://schema.org/PostalAddress" id="person-address" itemref="address-country">
<span itemprop="streetAddress">123 main</span>
</td>
<td itemprop="addressCountry" id="address-country">
USA
</td>
</tr>
</table>

或者将 Person 添加到第一个 td 中,在 table 中仍然有 Person:

<!-- can’t have this as descendant of another Microdata item -->

<table>
<tr>
<td itemscope itemtype="http://schema.org/Person" itemref="person-address">
<span itemprop="name">Name</span>
</td>
<td itemprop="address" itemscope itemtype="http://schema.org/PostalAddress" id="person-address" itemref="address-country">
<span itemprop="streetAddress">123 main</span>
</td>
<td itemprop="addressCountry" id="address-country">
USA
</td>
</tr>
</table>

关于html - 表格上的微数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29684960/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com