6

I have a link that looks like this:

<a href="//href" itemscope itemtype="http://schema.org/Product">
    <img src="src" itemprop="image">
</a>

I'd like to put itemprop="url" in the <a> tag, but it contains the itemscope for that product. Can I put that at the same level as itemtype=?

Or, do I either need to wrap the whole thing in a div to make it work, or use a <meta> tag for the itemprop="url" microdata? Thanks!

YPCrumble
  • 26,610
  • 23
  • 107
  • 172
  • This question appears to be off-topic because it is about SEO – John Conde Feb 19 '14 at 12:47
  • @JohnConde: I don’t think YPCrumble asks for [SEO advice](http://meta.stackexchange.com/q/217434/193139) here. – unor Feb 19 '14 at 14:44
  • 1
    Generally speaking, how to use mircodata tends to fall under the Pro Webmaster domain. This should probably be flagged to migrate there. – John Conde Feb 19 '14 at 14:45
  • @JohnConde: Why’s that? If Microdata usage questions should be moved to Webmasters SE, HTML usage question would have to be moved, too, as Microdata is an HTML5 extension. I didn’t have the feeling that such usage questions would be generally off-topic here on SO. I agree that these could also be posted on Webmasters, but that doesn’t necessarily mean that they are off-topic here (same case with the specific Wordpress/Drupal SE’s: it’s still on-topic to ask about them on SO). – unor Feb 20 '14 at 10:08
  • Mricodata *isn't* HTML. It is used in *conjunction* with HTML. And its *sole purpose* is SEO as it is designed to tell only search engines more about some content. So any questions as to its use fall under SEO and is thus the domain of Pro Webmasters, – John Conde Feb 20 '14 at 12:40

2 Answers2

6

You can have itemprop and itemscope on the same element, but it will mean something different.

In this example, a Product item has the url property:

<div itemscope itemtype="http://schema.org/Product">
  <a href="//href" itemprop="url">…</a>
</div>

In this example, some other item has the url property, and its value is a Product item:

<a href="//href" itemprop="url" itemscope itemtype="http://schema.org/Product">…</a>

(Note for the the latter case: the url value is the Product item, not the URL in the href attribute! So this probably doesn’t make sense for the url property.)

unor
  • 92,415
  • 26
  • 211
  • 360
0

No you don't need another wrapper to do that. You can specify itemprop="url" to the a tag.

This technique called "nested scope"

More about this is available at section 2.2 The basic syntax of this link http://www.w3.org/TR/2011/WD-microdata-20110525/

Toan Nguyen
  • 11,263
  • 5
  • 43
  • 59
  • On the page you reference it says "To add a property to an item, the itemprop attribute is used on one of the item's descendants."; wouldn't that mean that I have to put the itemprop property on a descendant rather than the element that contains itemscope? – YPCrumble Feb 19 '14 at 10:37
  • @YPCrumble No, it doesn't mean that. It means that once you have define your itemtype(which is your vocabulary) on an element, you can put itemprop="value" to the children of that element. Consider itemtype =vocabulary of things, and itemprop = an entry in that vocabulary. – Toan Nguyen Feb 19 '14 at 10:52
  • @Toan_Nguyen I just tried it on GWT structured data testing and it appears you have to use a child element: http://www.google.com/webmasters/tools/richsnippets?q=uploaded:8004f2c03e1aefb7c5db862ec6b15b43 – YPCrumble Feb 19 '14 at 10:58
  • @YPCrumble OK, so in your case, itemprop="url" belongs to http://schema.org/Product? If that is the case, then you need a wrapper. If itemprop="url" belongs to another schema(for instance http://schema.org/Thing), you have defined in an ancestor item, then you wouldn't need. – Toan Nguyen Feb 19 '14 at 11:06