Kev*_*son 5 html microdata rich-snippets
我正在尝试向我的网站添加一些丰富的代码片段,并且我在使用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>
Run Code Online (Sandbox Code Playgroud)
据我所知,这是有效的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>
Run Code Online (Sandbox Code Playgroud)
这似乎是正确的.
你的做法是正确的。只需在适当的位置添加标签并将值设置为“ ratingValue”即可。当页面呈现给用户时,它不会显示。
所以你会使用这个标签:
<meta itemprop="ratingValue" content="4.5">
在你的文档的范围内,http://schema.org/Review就像你在更新中显示的那样。