Use of Itemid and itemref attributes in HTML5 elements?

Asked

Viewed 88 times

0

I would like to understand the correct semantic functioning of the Microdata Itemid and itemref attributes in the HTML5 elements. Thank you!

  • 1

    I understand your good intention, but I recommend that you search before asking a new question, there are several answers already on the site, our search engine is well advanced http://answall.com/help/searching ;)

  • I edited to improve the focus of the question. Thank you! :)

1 answer

1


As already explained here What is the "application/Ld+json" type for in a <script tag>? this is the foundation of Microdata, Rdfa and JSON-LD, they serve to facilitate crawlers to extract the data and provide better user experience in search results (Of course they can probably be used for other purposes, depending on who or which tool is interested in this data).

Summarizing they teach your website to speak :)

Already in Microdata the attributes:

  • itemscope - creates the item and indicates that the descendants of that element contain information about it.
  • itemtype - Must contain a valid URL describing the item and its context properties.
  • itemid - Must contain a unique item identifier.
  • itemprop - Indicates that its tag containing retains the property value of the specified item. Name and context value of the property are described by item vocabulary. Property values usually consist of string values, but you can also use Urls using the href element and its attribute, the img element and its src attribute, or other elements that point to external resources or embed.
  • itemref - properties that are not descended from the element with the attribute itemscope 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.

Microdata can be used to describe several things, so there are several ways to describe something, for example want to 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 in addition to avoiding obstructing the HTML will adjust in maintenance and organization without mixing the data.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.