Search code examples
htmlhyperlinkschema.orgmicrodataphone-number

Is a wrapping span element necessary for a Schema.org telephone link?


The examples I often see for using Schema.org Microdata use a lot of extra span elements, such as the following:

<span itemprop="telephone">
  <a href="tel:+18506484200">
     850-648-4200
  </a>
</span>

Is the extra span element really necessary or is it acceptable to place the itemprop in the a tag? Like so:

<a href="tel:+18506484200" itemprop="telephone">
     850-648-4200
</a>

The latter example seems so much cleaner, but the examples I see always seem to use separate span elements.


Solution

  • The span element would generate a Text value, the a element would generate a URL value (details).

    Schema.org’s telephone property expects a Text value:

    Values expected to be one of these types
    Text

    Note that you don’t have to follow this advice. It is possible to use values that are not expected. There is an issue that asks to expect URL values, too: Make the telephone property more structured (not just Text).