Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Splitting schema.org Microdata over multiple divs or elements

The basic Microdata should be something like:

<div itemscope itemtype="http://schema.org/LocalBusiness">
<a itemprop="url" href="url"><div itemprop="name"><strong>name</strong></div>
</a>
<div itemprop="description">My Description</div>
<div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
<span itemprop="streetAddress">My Address</span><br>
<span itemprop="addressLocality">My City</span><br>
<span itemprop="postalCode">My Zip</span><br>
<span itemprop="addressCountry">My Country</span><br>
</div>
</div>

But can I "split" the itemscope along the page?

Giving an extreme example - Say I have the name at the header of a page, the address in the middle of the page, and the country at the footer.

Would it still be a valid / effective to split the data in such a way? or do I always need to use a cluster.

And if a split is valid, how exactly to perform it? Do I just need to repeat the divs like :

    <div itemscope itemtype="http://schema.org/LocalBusiness">
<div itemprop="name"><strong>name</strong></div>
</a>
    <div itemprop="description">My Description</div>

    </div>

And …

 <div itemscope itemtype="http://schema.org/LocalBusiness">

    <span itemprop="streetAddress">My Address</span><br>

    </div>

And …

   <div itemscope itemtype="http://schema.org/LocalBusiness">

    <span itemprop="country">My Country</span><br>

   </div>

This is my first time considering the use of Microdata - and I just want to make sure that I do it correctly - and I could not see any references to such a "split".

And on the same topic, can I use already existing elements, while adding only the itemscope?

For example:

<div itemscope itemtype="http://schema.org/LocalBusiness">
<h1><div id = "title" class="title" itemprop="name"><strong>name</strong></div></h1>
</a>
like image 761
Obmerk Kronen Avatar asked Jan 13 '14 06:01

Obmerk Kronen


2 Answers

The easiest is to have everything in the same hierarchical tree. But you can split things using itemref. See this example from the same document you linked to:

In the following example, the "a" property has the values "1" and "2", in that order, but whether the "a" property comes before the "b" property or not is not important:

<div itemscope>
  <p itemprop="a">1</p>
  <p itemprop="a">2</p>
  <p itemprop="b">test</p>
</div>

Thus, the following is equivalent:

<div itemscope>
  <p itemprop="b">test</p>
  <p itemprop="a">1</p>
  <p itemprop="a">2</p>
</div>

And the following:

<div itemscope itemref="x">
  <p itemprop="b">test</p>
  <p itemprop="a">2</p>
</div>
<div id="x">
  <p itemprop="a">1</p>
</div>
like image 123
Michaël Hompus Avatar answered Jan 03 '23 07:01

Michaël Hompus


No, a parser will probably see what you're suggesting as 3 separate Local Business entities.

But you can have other text between the various properties in http://schema.org/LocalBusiness as follows:

<div itemscope itemtype="http://schema.org/LocalBusiness">
  <a itemprop="url" href="url"><div itemprop="name"><strong>name</strong></div></a>
  <p>
     This paragraph is not used by schema.org
     Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam blandit pretium
     massa, in consectetur velit. Vivamus aliquam, turpis in pellentesque pulvinar,
     lectus diam fermentum velit, quis fermentum arcu turpis in orci. Duis egestas
     urna vel velit suscipit mollis. Nulla sed diam massa.
  </p>
  <div itemprop="description">My Description</div>
</div>
like image 21
Paul Watson Avatar answered Jan 03 '23 05:01

Paul Watson