Question

In all examples around the web I see Microdata properties itemscope and itemtype being applied to div elements, like so:

<div itemscope itemtype ="http://schema.org/Movie">
  <h1 itemprop="name">Avatar</h1>
  <span>Director: <span itemprop="director">James Cameron</span> (born August 16, 1954)</span>
  <span itemprop="genre">Science fiction</span>
  <a href="../movies/avatar-theatrical-trailer.html" itemprop="trailer">Trailer</a>
</div>

But can Microdata be applied on any other element, in my case I want to apply it to a list item:

<ul>
<li itemscope itemtype ="http://schema.org/Movie">
  <h1 itemprop="name">Avatar</h1>
  <span>Director: <span itemprop="director">James Cameron</span> (born August 16, 1954)</span>
  <span itemprop="genre">Science fiction</span>
  <a href="../movies/avatar-theatrical-trailer.html" itemprop="trailer">Trailer</a>
</li>
</ul>

Are there any known problems with this?

Was it helpful?

Solution 2

Simply put, "Yes". Check out the Google page yourself to see them use it in different tags: https://support.google.com/webmasters/answer/176035?hl=en

OTHER TIPS

You can use every HTML5 element for Microdata …

Microdata defines 5 new attributes for HTML5:

  • itemid
  • itemprop
  • itemref
  • itemscope
  • itemtype

Let’s see where they can be used. Section 5.2 says:

Every HTML element may have an itemscope attribute specified.

So every element can have itemscope. Further on it says:

Elements with an itemscope attribute may have an itemtype attribute specified

So if it has itemscope (and we learned that every element can have it), it can have itemtype, too. Next:

Elements with an itemscope attribute and an itemtype attribute […] may also have an itemid attribute specified

If it has itemscope and itemtype, it can have itemid, too. And:

Elements with an itemscope attribute may have an itemref attribute specified

If it has itemscope, it can have itemref.

Only itemprop is missing now. It’s defined in Section 5.3:

Every HTML element may have an itemprop attribute specified

So itemprop can also be used on every element.

(Note that Microdata (W3C Note) refers to the HTML5 spec for defining what a "HTML element" is, so essentially "HTML element" means "HTML5 element".)

… but some elements get a different content model (when itemprop is used)

See 8.1 Content models.

For example:

  • href becomes a required attribute for a and area
  • data becomes a required attribute for iframe
  • the attributes name, http-equiv and charset are no longer allowed on meta

… and some elements have special rules for determining the property value (when itemprop is used)

See 5.4 Values.

For example:

Special rules for links. Here foobar’s value is the URL http://example.com/, not the string Link:

<a href="http://example.com/" itemprop="foobar">Link</a>

Here foobar’s value is 5, not 10:

<data value="5" itemprop="foobar">10</data> 

And search engines should know this.

If Google or other search engine services support it can’t be answered definitely, as nothing can be answered with certainty when it comes to third party services that keep their code hidden. Even if they (seem to) support it today, we can’t know what will happen tomorrow. So such questions are usually not appropriate for Stack Overflow.

However, there is no reason to assume that search engines wouldn’t support it.

Adding to Jeremy Miller's answer:

Microdata essentially forms objects. In valid HTML, an element with the itemscope attribute contains all of the microdata associated with it. Also, the scope of each element with an itemprop is enough to contain all data necessary for that property.

Imagine replacing each itemscope element with the item itself; and replacing each itemprop element with the property itself, and its value. (Think XML)

In your example, the item would look like this:

<movie>
    <name>Avatar</name>
    <director>James Cameron</director>
    <genre>Science fiction</genre>
    <trailer>Trailer</trailer>
</movie>

This structure of itemscopes and itemprops can be applied to any suitable hierarchy of HTML elements, regardless of what elements they are. The long-winded answer is still yes, but I hope this has helped you understand how microdata is interpreted.

Also, I'm guessing your example is from here, but I suggest you give at least items 1a-1d a quick read.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top