W3C home > Mailing lists > Public > public-vocabs@w3.org > February 2012

Re: Two questions about itemprop

From: Jason Ronallo <jronallo@gmail.com>
Date: Sun, 26 Feb 2012 20:22:30 -0500
Message-ID: <CAKedLN0L1AvuqBdiUTvJpT6gb8gKv48Y3G+3V0ETRgnUzH9wjw@mail.gmail.com>
To: Chuck <chuck42@gmx.de>
Cc: public-vocabs@w3.org
Hi, Chuck,

Responses inline.

On Sat, Feb 25, 2012 at 11:02 AM, Chuck <chuck42@gmx.de> wrote:
> (1) It is true, that per HTML-element there can be just one
> `itemprop'?!

My reading of the specification says this is true and false. You can
have just one itemprop attribute per element but it can have more than
one value.

"Every HTML element may have an itemprop attribute specified... The
itemprop attribute, if specified, must have a value that is an
unordered set of unique space-separated tokens that are
case-sensitive, representing the names of the name-value pairs that it
adds. The attribute's value must have at least one token."
http://www.whatwg.org/specs/web-apps/current-work/multipage/microdata.html#names:-the-itemprop-attribute

You might try the nu validator or a microdata parser to test your code
and make sure you're getting the output you expect. [1]

> (2) Can I nest the `itemprop' attribute? Would the following code be correct?
>
> <div itemscope itemtype="http://schema.org/Person">
>   <a href="http://myhomepage.com" itemprop="url">
>      <img src="myimage.jpg" itemprop="image" />
>   </a>
> </div>

This looks alright to me. I think it is a common pattern to nest
itemprops like this especially with regards to elements that take
their values from an attribute (like the a and img elements) rather
than the text content. I've used this example to show how to get the
text content of a link, since placing the itemprop on the a element
would give the value of the href attribute instead:

<a href="/s/buildings"><span itemprop="keywords">Buildings</span></a>

Hope that helps. I'm also happy to be corrected if I'm wrong on either
of these points.

Jason

[1] http://validator.w3.org/nu/
http://foolip.org/microdatajs/live/
http://linter.structured-data.org/
Received on Monday, 27 February 2012 01:23:38 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 22 May 2012 06:48:59 GMT