3

I'd like to use the following code:

<div itemprop="aggregateRating" itemscope itemtype="https://schema.org/AggregateRating">
    <div>
      <span itemprop="ratingValue">[rating]</span> from
      <div style="display: none;" itemprop="bestRating">5</div>
      <span itemprop="ratingCount">[quantity]</span> reviews
    </div>
</div>

It's a typical 5-star rating system so displaying "5" is unnecessary.

Is display:none usable? If not, alternate suggestions are welcome.

I did try it in the structured data testing tool and it passed. However, I'm still worried that it may not work in the search engine.

2

For such a purpose, the meta element can be used. It’s visually hidden by default.

<meta itemprop="bestRating" content="5" />

(For representing a rating value in HTML, you could also use the meter element, which allows setting the min and max with HTML attributes.)

For the structured data, it doesn’t matter whether the data is visible or not.
For structured data consumers like search engines, it might matter, though, as search engines do not want to fall for manipulations, and hiding data could be a manipulation.

But there are clear cases where there is no reason to assume that hiding the data could be misunderstood to be manipulation, and your example is one of those cases. The fact that 5 is the max value is likely indicated in some way to your readers (e.g., graphically), so providing this information within a meta element is just providing it in a different, machine-readable format.

(NB: If the max value is 5, you could omit the bestRating property, as 5 is assumed; but I would argue that it’s usually a good practice to provide it anyway.)

1

Google may consider this as spam in structured data. Check the following information from Google guides Manual Actions report:

Structured data found on hidden content Structured data found on elements that are not visible to the user.

Don't do it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.