htmlschema.orgmicrodata

How to add 'name' and 'url' properties to the same tag?


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"

Solution

  • 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.