Re: Two questions about itemprop

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 UTC