2

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.

unor
  • 92,415
  • 26
  • 211
  • 360
dave
  • 2,762
  • 1
  • 16
  • 32

1 Answers1

2

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

Community
  • 1
  • 1
unor
  • 92,415
  • 26
  • 211
  • 360
  • By saying that I don't *have* to, are you suggesting that Google will probably parse the shortened markup even if it's not strictly valid? – dave Mar 02 '17 at 18:58
  • 1
    @dave: It’s the other way around. It is valid to use whatever value type you want, and every conforming Microdata parser will parse it correctly automatically. -- But each consumer (e.g., Google) decides which value types to support for which of their features (e.g., rich search results). Even if Schema.org would explicitly expect an `URL` value, a consumer could still decide to support only `Text` values (or vice versa). The consumer’s documentation will hopefully note if that’s the case, and if the documentation doesn’t, it hopefully means that they support Schema.org’s expected values. – unor Mar 02 '17 at 19:15