Itemref

itemref #

::: section-content Properties that are not descendants of an element with the itemscope attribute can be associated with an item using the global attribute itemref.

itemref provides a list of element IDs (not itemids) elsewhere in the document, with additional properties

The itemref attribute can only be specified on elements that have an itemscope attribute specified.

::: {#sect1 .notecard .note} Note: The itemref attribute is not part of the microdata data model. It is merely a syntactic construct to aid authors in adding annotations to pages where the data to be annotated does not follow a convenient tree structure. For example, it allows authors to mark up data in a table so that each column defines a separate item while keeping the properties in the cells. ::: :::

Examples #

Representing structured data for a band #

::: section-content This example uses microdata attributes to represent the following structured data (in JSON-LD{target="_blank"} format):

::: code-example [json]{.language-name}

{
  "@id": "amanda",
  "name": "Amanda",
  "band": {
    "@id": "b",
    "name": "Jazz Band",
    "size": 12
  }
}

:::

HTML #

::: code-example [html]{.language-name}

<div itemscope id="amanda" itemref="a b">
<p id="a">Name: <span itemprop="name">Amanda</span></p>
<div id="b" itemprop="band" itemscope itemref="c">
<div id="c">
  <p>Band: <span itemprop="name">Jazz Band</span></p>
  <p>Size: <span itemprop="size">12</span> players</p>

:::

Result #

::: {#sect2 .code-example} ::: iframe ::: ::: :::

Specifications #

::: _table #

Specification #

HTML Standard
[# attr-itemref]{.small}


:::

Browser compatibility #

::: _table Desktop Mobile


          Chrome    Edge   Firefox   Internet Explorer   Opera   Safari   WebView Android   Chrome Android   Firefox for Android   Opera Android   Safari on IOS   Samsung Internet

itemref Yes 12 Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes :::

See also #

::: section-content

::: _attribution © 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/itemref{._attribution-link} :::