16

I'm adding the schema.org Microdata to my website.

My HTML code is like this:

<div itemscope itemtype="http://schema.org/Organization">
<span class="title">Name of the organization</span>
<a href="http://www.ABCCompany.com/">ABC Company</a>
</div>

Since the itemprop "url" and "name" of the Organization are all in the anchor tag. How can I indicate the both "url" and "name" itemprop on the same tag? Must I add extra span tag for this purpose?

I have tried searching some coding examples on this but cannot find any example to show the use of multiple itemprop on the same tag.

At the end, I want to have Microdata like this:

url="http://www.ABCCompany.com", name="ABC Company"
unor
  • 92,415
  • 26
  • 211
  • 360
LazNiko
  • 2,083
  • 3
  • 25
  • 39
  • Knut asked to have his answer deleted as @cygri has provided the correct answer. You might wish to review this and select it if his answer helps. –  Jul 26 '11 at 12:44

4 Answers4

32

You have to do it by nesting two elements. For example, you can nest a <span> inside the <a> and put the itemprop="name" on that:

<div itemscope itemtype="http://schema.org/Organization">
    <a itemprop="url" href="http://www.ABCCompany.com/">
        <span itemprop="name">ABC Company</span>
    </a>
</div>

I find this site handy for testing such things.

cygri
  • 9,412
  • 1
  • 25
  • 47
2

There may be a problem with google. The "rich snippets testing tool" indicates that when you mark an anchor tag as a url, the body of the tag is used as value rather than the href attribute. But nobody wants to display the url inside an anchor tag.

ole
  • 21
  • 1
  • 2
    If you use the rich snippets testing tool, and you have itemprop='name' on the anchor, it will show the text inside the href as a linked item, so it looks like that works, and it almost seems like you got 'url' and 'name' in one fell swoop. HOWEVER, if you look in Webmaster Tools, you will see that itemprop='name' is actually using the the URL for the name property. In my experience, you need to have itemprop='url' on the anchor, and then a span inside the anchor with itemprop='name' on it. The testing tool is really deceiving. – Petercopter Jul 29 '13 at 19:20
0

This also works and may look a bit easier to maintain:

<div itemscope itemtype="http://schema.org/Organization">
<span class="title" itemprop="name"><a itemprop="url" href="http://www.ABCCompany.com/">ABC Company</span></a>
</div>

Google's support for schema.org and the google structured data tester have improved considerably since the original question was posted. The code above validates correctly in it.

Mousey
  • 1,855
  • 19
  • 34
-1

The OP's original code now seems to work ok. As shown here:

https://search.google.com/structured-data/testing-tool#url=http%3A%2F%2Fmercedes-benzhanoi.com.vn%2Fmercedes-ha-noi.auto%2Fgla-250-4matic.html

<div itemscope="" itemtype="http://schema.org/Organization"> <span class="title" itemprop="name"> <a itemprop="url" href="http://mercedes-benzhanoi.com.vn/mercedes-ha-noi.auto/gla-250-4matic.html">GLA 250 4MATIC</a></span> </div>

Alexander Morley
  • 4,111
  • 12
  • 26