Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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"
like image 621
LazNiko Avatar asked Jul 24 '11 07:07

LazNiko


People also ask

Can we give name to anchor tag?

An anchor name is the value of either the name or id attribute when used in the context of anchors. Anchor names must observe the following rules: Uniqueness: Anchor names must be unique within a document. Anchor names that differ only in case may not appear in the same document.

What is an anchor tag in HTML?

The <a> HTML element (or anchor element), with its href attribute, creates a hyperlink to web pages, files, email addresses, locations in the same page, or anything else a URL can address.

What is anchor tag explain with example?

The <a> tag (anchor tag) in HTML is used to create a hyperlink on the webpage. This hyperlink is used to link the webpage to other web pages or some section of the same web page. It's either used to provide an absolute reference or a relative reference as its “href” value.


1 Answers

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.

like image 62
cygri Avatar answered Sep 17 '22 19:09

cygri