我正在尝试向我的网站添加一些丰富网页摘要,但在 AggregateRating 部分遇到了一些困难,因为我的 ratingValue 的值仅显示为图像。
我的标记如下所示:
<tr itemprop="reviews" itemscope itemtype="http://schema.org/Review">
<th>Rating:</th>
<td itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
<img itemprop="ratingValue" class="rating" src="/content/images/ratings/4.5.png" alt="4.5" title="Rating: 4.5 / 5" />
</td>
</tr>
据我所知,这是有效的 HTML,因为文本值可作为 ALT 文本使用,因此符合可访问性指南。但是,我不确定如何将此 ALT 标记为 ratingValue 的值。
有人知道我应该在这里做什么吗?
谢谢。
好的,在使用 Google Rich Snippets Tester 数小时后,我得出的结论是:
<tr itemprop="reviews" itemscope itemtype="http://schema.org/Review">
<th>Rating:</th>
<td itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
<meta itemprop="ratingValue" content="4.5">
<img class="rating" src="/content/images/ratings/4.5.png" alt="4.5" title="Rating: 4.5 / 5" />
</td>
</tr>
这似乎被正确地拾取了。
最佳答案
您的做法是正确的。只需在适当的位置添加一个标签并将值设置为“ratingValue”。它不会在页面呈现给用户时显示。
所以你会使用这个标签:
<meta itemprop="ratingValue" content="4.5">
在http://schema.org/Review
范围内在您的文档中,就像您在更新中显示的那样。
关于html - 当值为图像时使用 AggregateRating 和 ratingValue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6889256/