What the spec says
Yes, that behaviour is correct. Section 5.4 of the W3C Microdata spec describes which value gets used.
In most cases, the element’s content gets used as itemprop
value, but in some cases, an attribute’s value gets used as itemprop
value.
This is the case for these six attributes¹: content
², src
, href
, data
, value
, datetime
.
What this means in practice
If you want to use the content of an a
element (instead of the URL in its href
attribute) as property value, you have to use/add a suitable parent or child element:
<a href="ignored-url"><span itemprop="property">property value</span></a>
<span itemprop="property"><a href="ignored-url">property value</a></span>
If you want to provide a URL as property value, you must use itemprop
on one of the URL property elements (i.e., elements that can³ have a href
, src
, or data
attribute). So this would be invalid (unless you want to provide a string as value which just looks like a URL):
<!-- INVALID --> <span itemprop="property">http://example.com/foo</span>
¹ It must be valid for the element to have this attribute. So for an (invalid!) <div href="" itemprop=""></div>
, the element content gets used, not the href
value.
² In WHATWG’s and W3C’s old spec of Microdata, only the meta
element can have the content
attribute, but the new W3C Microdata spec (currently a Working Draft) allows content
on any element. If an element has a content
attribute and also one of the other listed attributes, content
gets used.
³ Microdata makes it invalid to have one of the URL property elements without their respective URL attribute (i.e., href
, src
, data
), except for the link
element (but it’s already required by HTML to have the href
attribute).