我可以在跨度标记中为schema.org丰富网页摘要使用多个ItemProp吗? [英] Can I Use Multiple ItemProps in a Span Tag for schema.org Rich Snippets?

查看:93
本文介绍了我可以在跨度标记中为schema.org丰富网页摘要使用多个ItemProp吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有以下句子,我想添加丰富网页摘要:

Let's say I have the following sentence I want to add rich snippets to:


我在纽约生活和工作

I live and work in New York

由于纽约既是我的居住地,也是我工作的城市,理论上我希望使用schema.org标准标记这样的行:

Since New York is both my residency and the city where I work in, I would theoretically want to tag the line like this using schema.org standards:

<div itemscope itemtype = 'http://schema.org/Person'>I live and work in 
<span itemprop = 'homeLocation'  itemprop = 'workLocation'>New York</span></div>

在一个span标签中有两个itemprops是否有效?如果没有,下面的工作会吗?

Is it valid to have 2 itemprops in one span tag? If not, will the below work?

<div itemscope itemtype = 'http://schema.org/Person'>I live and work in 
<span itemprop = 'homeLocation'><span itemprop = 'workLocation'>New York
</span></span></div>


推荐答案

通常的HTML方法是使用一个属性并用空格字符分隔几个值。

The usual HTML way would be to use one attribute and separate several values with space characters.

纵观Microdata规范,您会注意到这是 itemprop 属性
$ b

Looking into the Microdata specification, you’ll notice that this is the case for the itemprop attribute, too:


itemprop 属性(如果指定)必须有一个值这是一个无序的独特空间分隔标记集合[/ b] [b]

The itemprop attribute, if specified, must have a value that is an unordered set of unique space-separated tokens […]

所以这应该是正确的: $ b

So this should be correct:

<div itemscope itemtype="http://schema.org/Person">
  I live and work in <span itemprop="homeLocation workLocation">New York</span>
</div>

(注意:如果使用 itemprop CSS选择器,请使用 [att〜= val] 而不是 [att = val] 。)

(Note: If using itemprop values as CSS selector, use [att~=val] instead of [att=val].)

这篇关于我可以在跨度标记中为schema.org丰富网页摘要使用多个ItemProp吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆