Skip to content Skip to sidebar Skip to footer

Microdata On Tables

I’m new to Microdata and have a problem with itemscope within a table. For example assume I‘ve got a person object and in the table I’m showing Name, Street and City columns.

Solution 1:

There are only rather ugly solutions for this.

You could use the itemref attribute for the country, but you’d have to add a dummy untyped itemscope so that the addressCountry property doesn’t get added to the Person item:

<table><tritemscopeitemtype="http://schema.org/Person"><tditemprop="name">
      Name
    </td><tditemprop="address"itemscopeitemtype="http://schema.org/PostalAddress"itemref="country"><spanitemprop="streetAddress">123 main</span></td><tditemscope><spanitemprop="addressCountry"id="country">USA</span></td></tr></table>

You could use itemref for almost anything, so that you don’t have to add a dummy itemscope, but the markup gets more complex, and you have to "outsource" the Person item:

<metaitemscopeitemtype="http://schema.org/Person"itemref="person-name person-address" /><!-- can’t have this as descendant of another Microdata item --><table><tr><tditemprop="name"id="person-name">
      Name
    </td><tditemprop="address"itemscopeitemtype="http://schema.org/PostalAddress"id="person-address"itemref="address-country"><spanitemprop="streetAddress">123 main</span></td><tditemprop="addressCountry"id="address-country">
      USA
    </td></tr></table>

Or still have Person in the table by adding it to the first td:

<!-- can’t have this as descendant of another Microdata item --><table><tr><tditemscopeitemtype="http://schema.org/Person"itemref="person-address"><spanitemprop="name">Name</span></td><tditemprop="address"itemscopeitemtype="http://schema.org/PostalAddress"id="person-address"itemref="address-country"><spanitemprop="streetAddress">123 main</span></td><tditemprop="addressCountry"id="address-country">
      USA
    </td></tr></table>

Post a Comment for "Microdata On Tables"