Daniel Schreurs
Daniel Schreurs

Reputation: 371

I can't directly apply itemprop="telephone" to the <a> tag?

I'm a bit puzzled by a behavior I'm observing when trying to add microdata to my page. Specifically, I have a link in my page that includes a phone number, which seems like a standard practice. I wanted to add itemprop="telephone" to this link. However, when I validate it using the validator at schema.org, it doesn't seem to recognize the phone number.

using the following code:

<a itemprop="telephone" href="tel:000 00 00 00" title="... 000 00 00 00">000 00 00 00</a>

But if I wrap the link with a <p> tag and add itemprop="telephone" to the <p> tag like this:

<p itemprop="telephone">
    <a href="tel:000 00 00 00" title="... 000 00 00 00">
        000 00 00 00
    </a>
</p>

…it works as expected.

Can anyone shed some light on why I can't directly apply itemprop="telephone" to the tag? Thanks in advance!

Upvotes: 2

Views: 66

Answers (1)

Schema.org’s telephone property expects a text value, not a URL value.

If you provide Microdata’s itemprop attribute on an a element, it uses the href content as value (i.e., a URL). If you provide the itemprop attribute on a p element, it uses the element content as value (i.e., text).

To provide a text value, you could also use the meaningless span element:

<a href="tel:000-00-00-00">
  <span itemprop="telephone">000 00 00 00</span>
</a>

(Note that tel URIs must not contain spaces.)

Upvotes: 3

Related Questions