Sebass van Boxel
Sebass van Boxel

Reputation: 2602

Different div, same itemscope

I just started updating my website with Schema.org put one thing doesn't works out how expected it.

I want to apply the following properties to a newsarticle:

The problem is, these properties are not all in the same div. So basicly you'll see it like:

enter image description here

What happens is, is when I test it with Google Rich Snippets tester the second div is placed as a property of 'webpage' instead of a property of 'newsarticle'.

How should this be fixed? Or do I have to change my whole layout?

Edit: Before you suggest, at the moment it's not possible to put div 1 and div 2 into 1 wrapper because of the rest of the layout.

Upvotes: 3

Views: 324

Answers (1)

Alohci
Alohci

Reputation: 82986

Use the itemref attribute on the same element as the itemscope attribute. Like this:

<!DOCTYPE html>
<title>Test</title>
<div id="div1" itemref="dpub auth" itemscope itemtype="http://schema.org/NewsArticle" >
  <div itemprop="name">Article Name</div>
</div>
<div id="div2">
  <div id="dpub" itemprop="datepublished">September 1 2012</div>
  <div id="auth" itemscope itemprop="Author" >
    <div itemprop="name">John Smith</div>
    <div itemprop="url">http:/www.example.net</div>
  </div>
</div>

Check it out in the snippets testing tool

Upvotes: 3

Related Questions