Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I Use Multiple ItemProps in a Span Tag for schema.org Rich Snippets?

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

I live and work in New York

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> 

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> 
like image 490
Lloyd Banks Avatar asked Jan 07 '13 15:01

Lloyd Banks


People also ask

How do you use Itemprop?

To label properties of an item, use the itemprop attribute. For example, to identify the director of a movie, add itemprop="director" to the element enclosing the director's name. (There's a full list of all the properties you can associate with a movie at https://schema.org/Movie.)

What is microdata markup?

Microdata is a specification to embed machine-readable data in HTML documents. Microdata consists of name-value pairs (known as items ) defined according to a vocabulary. A collection of commonly used markup vocabularies are provided by schema.org.

What is Itemscope?

itemscope is a boolean global attribute that defines the scope of associated metadata. Specifying the itemscope attribute for an element creates a new item, which results in a number of name-value pairs that are associated with the element.


1 Answers

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

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

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

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> 

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

like image 137
unor Avatar answered Sep 20 '22 08:09

unor