4

I'm using schema.org definition to represent a product. I have a doubt about product size: should I specify the unit of measure in the field?

Here's my code (I need a separate span for "cm" to style it differently):

<div itemscope itemtype="http://schema.org/Product">
    <h1 itemprop="name">Product name</h1>

    Size: 
    <span itemprop="width">60 <span>cm</span></span>
    <span itemprop="height">50 <span>cm</span></span>
    <span itemprop="depth">40 <span>cm</span></span>
</div>

Is this the correct way to define the size?

unor
  • 92,415
  • 26
  • 211
  • 360
ninjabachelor
  • 146
  • 1
  • 2
  • 10

1 Answers1

10

The width/depth/height properties expect Distance or QuantitativeValue as value.

If you want to use Distance:

As the Distance type does not seem to define a suitable property to provide the actual value, and its description says that values have

[…] the form '<Number> <Length unit of measure>'. E.g., '7 ft'.

I assume that the type should not be provided explicitly, e.g.:

<span itemprop="width">
  60 <span>cm</span>
</span>

If the type should be provided, I guess using name is the only option:

<span itemprop="width" itemscope itemtype="http://schema.org/Distance">
  <span itemprop="name">60 <span>cm</span></span>
</span>

If you want to use QuantitativeValue:

<span itemprop="width" itemscope itemtype="http://schema.org/QuantitativeValue">
  <span itemprop="value">60</span>
  <span>cm</span>
  <meta itemprop="unitCode" content="CMT" />
</span>

Instead of specifying the UN/CEFACT code for "cm" (= CMT) in a meta element (which is allowed in the body, if you use it for Microdata), you could also use the data element:

<span itemprop="width" itemscope itemtype="http://schema.org/QuantitativeValue">
  <span itemprop="value">60</span>
  <data itemprop="unitCode" value="CMT">cm</data>
</span>
Community
  • 1
  • 1
unor
  • 92,415
  • 26
  • 211
  • 360
  • What is a `data` element? Given the OP, is seems like that should be a `span`? – Dan Friedman Feb 11 '15 at 16:32
  • @DanFriedman: [`data`](http://www.w3.org/TR/2014/REC-html5-20141028/text-level-semantics.html#the-data-element) is an HTML5 element. I explained in my answer why `span`+`data` or `span`+`meta` should be used for [`QuantitativeValue`](http://schema.org/QuantitativeValue). Could you clarify what exactly is unclear? – unor Feb 11 '15 at 17:36
  • 1
    @unor Thanks for the good example. The HTML of Distance is smaller and easier to create, so is there any benefit of using QuantitativeValue? Does all search engines treat 'Distance' and 'QuantitativeValue' similarly? – Ethan Mar 22 '15 at 09:06
  • Hi @unor or other reader - any knowledge of how to accomplish similar using JSON LD markup? Please see https://stackoverflow.com/questions/67754758/how-to-specify-product-dimensions-or-weight-including-unit-of-measure-in-schem thanks! =) – Drewdavid May 30 '21 at 01:35