Use of itemid and itemref attributes in HTML5 elements? [duplicate]

0

I would like to understand the correct semantic operation of the microdata itemid and itemref attributes in HTML5 elements. Thank you!

    
asked by anonymous 22.03.2016 / 00:49

1 answer

1

As already explained here What is the "application / ld + json" type in a < script >? Tag this is Microdata, RDFa, and JSON-LD, serve to make it easier for crawlers to extract data and provide better experience to the user in the search results (of course, they can probably serve other purposes, it will depend on who or what tool is interested in that data).

  

In short they teach your site how to talk:)

Already in the microdata the attributes:

  • itemscope - creates the item and indicates that the descendants of this element contain information about it.
  • itemtype - Must contain a valid URL that describes the item and its context properties.
  • itemid - Must contain a unique identifier of the item.
  • itemprop - Indicates that its containing tag retains the property value of the specified item. The name and context value of the property are described by the item's vocabulary. Property values usually consist of string values, but you can also use URLs using the element and its href attribute, the img element and its src attribute, or other elements that point to external resources or embed.
  • itemref - properties that are not descendants of the element with the itemscope attribute can be associated with the item using this attribute. Provides a list of element ids (not item id) with additional properties in other parts of the document.

The microdata can be used to describe several things, so there are several ways to describe something, for example describe a person:

<section itemscope itemtype="http://schema.org/Person"> 
    Hello, my name is 
    <span itemprop="name">John Doe</span>, 
    I am a 
    <span itemprop="jobTitle">graduate research assistant</span> 
    at the 
    <span itemprop="affiliation">University of Dreams</span>. 
    My friends call me 
    <span itemprop="additionalName">Johnny</span>. 
    You can visit my homepage at 
    <a href="http://www.JohnnyD.com" itemprop="url">www.JohnnyD.com</a>. 
    <section itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
        I live at 
        <span itemprop="streetAddress">1234 Peach Drive</span>,
        <span itemprop="addressLocality">Warner Robins</span>,
        <span itemprop="addressRegion">Georgia</span>.
    </section>
</section>
  

However I recommend using json-ld, as well as avoiding to obstruct the HTML will adjust in the maintenance and organization without mixing the data.

    
22.03.2016 / 01:13