I wonder if it makes any difference whether I markup an item on my site like this:
<h1 itemprop="name"><a href="some-page.html">Joe Doe</a></h1>
or like this:
<h1><a href="some-page.html" itemprop="name">Joe Doe</a></h1>
Webmasters Stack Exchange is a question and answer site for webmasters. It only takes a minute to sign up.
Sign up to join this communityIt depends on the element.
In your example, the name
value isn’t the same. In the first snippet it’s the string "John Doe", in the second snippet it’s the relative URL Joe Doe
(i.e., not what you want to convey). It’s because of the a
element.
All elements that generate URL values if they have the itemprop
attribute:
src
attribute:audio
, embed
, iframe
, img
, source
, track
, video
href
attribute:a
, area
, link
data
attribute:object
If the value is a URL, you have to use one of these elements.
All other elements generate text values. If you nest them, it doesn’t make a relevant difference on which level you specify the itemprop
element: the value will be the textContent of all nested elements (example in this answer).
But note that some of the text value elements use attributes instead of the element content, so if you specify the itemprop
attribute on these elements, the nested elements are ignored:
content
attribute:value
attribute:data
, meter
datetime
attribute:time