将价格货币微数据(schema.org)插入html表中



我有以下一段代码:

<tr><th>Availability:</th>
  <td><link itemprop="availability" href="http://schema.org/InStock"/>available</td></tr>
<tr><th>Price:</th>
  <td itemprop="price">$137</td></tr>
<meta itemprop="priceCurrency" content="USD" />
</tbody>

不幸的是,它不验证: Start tag meta seen in table.

我如何插入价格货币并使验证正确?

您可以将meta元素放在td中,并将price属性移动到span中(否则价格值将包含字符串"USD")。

<tr>
  <th>Price:</th>
  <td>
    <span itemprop="price">137</span>
    <meta itemprop="priceCurrency" content="USD" />
  </td>
</tr>

对@unor的回答有一点建议。物品属性"price"不能包含任何符号,只能包含数字。

使用pricecurcy属性(使用ISO 4217代码,例如:"USD"),而不是在值中包含诸如"$"之类的模糊符号。

裁判:http://schema.org/price

<span itemprop="price">$137</span>

这一行应该是这个

<span itemprop="price">137</span>

以上答案是正确的。另一种可能的方式是:

<tr>
  <th>Price:</th>
    <td>
      <span itemprop="price">$137</span> 
        (<abbr title="United States Dollars" itemprop="priceCurrency">USD</abbr>)
    </td>
</tr>

通过使"美元"对网站访问者可见,您可以消除访问者对"美元"指的是什么货币(美元,加元,澳元等)的任何可能的混淆

<div itemscope itemtype="http://schema.org/Product">
  <meta itemprop="name" content="product name" />
  <meta itemprop="gtin14" content="00886227537143" />
  <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
    <meta itemprop="price" content="55.00" />
    <meta itemprop="priceCurrency" content="USD" />
    <meta itemprop="availability" content="http://schema.org/InStock" />
    <meta itemprop="itemCondition" content="http://schema.org/NewCondition" />
  </div>
</div>

包含schema.org/offer:

很重要
<tr itemprop="offers" itemscope itemtype="http://schema.org/Offer">
  <th>Price:</th>   
  <td><span>$</span><span itemprop="price">137</span>
    <meta itemprop="priceCurrency" content="USD" />   
  </td> 
</tr>

相关内容

最新更新