Microdata on tables

后端 未结 1 930
星月不相逢
星月不相逢 2020-12-16 23:31

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 sho

相关标签:
1条回答
  • 2020-12-17 00:21

    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>
      <tr itemscope itemtype="http://schema.org/Person">
        <td itemprop="name">
          Name
        </td>
        <td itemprop="address" itemscope itemtype="http://schema.org/PostalAddress" itemref="country">
          <span itemprop="streetAddress">123 main</span>
        </td>
        <td itemscope>
          <span itemprop="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:

    <meta itemscope itemtype="http://schema.org/Person" itemref="person-name person-address" />
    
    <!-- can’t have this as descendant of another Microdata item -->
    
    <table>
      <tr>
        <td itemprop="name" id="person-name">
          Name
        </td>
        <td itemprop="address" itemscope itemtype="http://schema.org/PostalAddress" id="person-address" itemref="address-country">
          <span itemprop="streetAddress">123 main</span>
        </td>
        <td itemprop="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>
        <td itemscope itemtype="http://schema.org/Person" itemref="person-address">
          <span itemprop="name">Name</span>
        </td>
        <td itemprop="address" itemscope itemtype="http://schema.org/PostalAddress" id="person-address" itemref="address-country">
          <span itemprop="streetAddress">123 main</span>
        </td>
        <td itemprop="addressCountry" id="address-country">
          USA
        </td>
      </tr>
    </table>
    
    0 讨论(0)
提交回复
热议问题