Can one HTML element provide several microdata properties?

The Citead team, updated

In short. One itemprop value can contain several unique property names separated by ASCII whitespace.

Definition: Yes. The WHATWG HTML Standard defines an itemprop value as an unordered set of unique space-separated tokens. One element can therefore provide several property names, with the value split on ASCII whitespace and duplicate names removed after their first occurrence.

Key facts

  • The WHATWG HTML Standard requires an itemprop value to contain at least one unique, space-separated token.
  • MDN's itemprop reference describes itemprop as a global attribute that adds properties to an item, with each name-value pair forming a property.
  • Schema.org's Microdata guide uses itemprop to label properties such as name, director, genre, and trailer on a movie item.

How does one itemprop attribute represent several properties?

The HTML Standard says that the property names of an element are the tokens in its itemprop value after the value is split on ASCII whitespace. The order is preserved, while duplicates are removed and only the first occurrence of each name remains. A single space is therefore a separator between property names, not part of a property name.

<div itemscope itemtype="https://schema.org/Thing">
  <span itemprop="name description">Example item</span>
</div>

In this example, the span supplies the same element value under the name and description property names. The syntax is different from writing two separate itemprop attributes on the same element: the HTML attribute has one value, and that value contains multiple tokens.

What makes each token valid?

The HTML Standard requires every token to be a permitted defined property name for the relevant typed item, an allowed absolute property URL, or a permitted proprietary name in the situations it describes. For an untyped item, a proprietary name is a string without a full stop or colon. Defined property names also cannot contain ASCII whitespace, because whitespace would make them multiple tokens.

The tokens form a set, so repeating a name does not create a second property name in the element's property-name list. Properties within an item are unordered relative to one another, except that properties with the same name retain the order supplied by the microdata algorithm.

How should a website use the markup?

MDN describes itemprop as available on every HTML element and says that a property value is either a string or a URL. The element type supplies the value according to HTML's microdata rules, while the tokens in itemprop supply the property names.

Schema.org's guide shows itemprop on elements enclosing the relevant text and says that span elements do not change how a browser renders the page, which makes them convenient for this markup. With a Schema.org type, use property names allowed for that type. The guide identifies name and description as properties of the broad Thing type, which is why they appear in the example above.

FAQ

Is the separator a comma?

No. The HTML Standard defines the value as space-separated tokens and says that property names are found by splitting on ASCII whitespace. A comma remains part of a token rather than separating two property names.

Can the same property name appear twice in the value?

The value is defined as a set of unique tokens. If a name is repeated, the property-name list keeps its first occurrence.

Does one element need one itemprop attribute per property?

No. One itemprop attribute can contain several space-separated names. Separate elements remain useful when the properties have different values.

Sources

  1. WHATWG, "HTML Standard, Microdata", null
  2. MDN Web Docs, "itemprop HTML global attribute", null
  3. Schema.org, "Getting Started", null

Check how a page reads to answer engines. Open the GEO score analyzer

Test a page and see what to fix first

The analysis usually takes less than 10 seconds and needs no account.

400,000+ pages scored in the public benchmark