CSS Portal

HTML itemscope Global Attribute

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The itemscope attribute is a global HTML attribute used to define the scope of a microdata item. Microdata is a way to embed structured data within HTML documents, allowing search engines, web crawlers, and other tools to better understand the content of your page.

When you add itemscope to an HTML element, it indicates that the element represents a single item with properties, which can then be described using other microdata attributes like itemprop and itemtype.

How It Works
  • Declaring an item: Adding itemscope to an element marks it as a container for a microdata item. It tells browsers and search engines that this element has properties that can be enumerated.

  • Optional itemtype: Often, itemscope is combined with itemtype to specify the type of item (using a URL that defines a vocabulary, usually from Schema.org). This gives semantic meaning to the data.

  • Child properties: Elements inside an itemscope element can have the itemprop attribute, defining properties of that item. These child elements are considered part of the scope of the item.

Syntax
<!-- Basic itemscope usage -->
<div itemscope>
  <span itemprop="name">Sample Item</span>
  <span itemprop="description">This is a description of the item.</span>
</div>

<!-- Using itemscope with itemtype -->
<div itemscope itemtype="https://schema.org/Product">
  <span itemprop="name">Chocolate Bar</span>
  <span itemprop="brand">Sweet Co.</span>
  <span itemprop="price">$2.50</span>
</div>
Key Points
  1. Global attribute: itemscope can be used on almost any HTML element because it is global.

  2. Boolean attribute: It does not require a value; just including it is enough. Example: <div itemscope>.

  3. Creates a microdata scope: Only child elements within the itemscope container with itemprop attributes are considered part of the item.

  4. Works with itemtype and itemid:

    • itemtype: Specifies the type of item.
    • itemid: Provides a unique identifier for the item.
  5. Supports nested items: You can have itemscope elements inside other itemscope elements to represent hierarchical data.

Example of Nested Items
<div itemscope itemtype="https://schema.org/Person">
  <span itemprop="name">John Doe</span>
  <div itemscope itemprop="address" itemtype="https://schema.org/PostalAddress">
    <span itemprop="streetAddress">123 Main St</span>
    <span itemprop="addressLocality">Springfield</span>
    <span itemprop="postalCode">12345</span>
  </div>
</div>
  • Here, the address property of the Person item is itself a nested microdata item.

Syntax

<div itemscope itemtype="https://schema.org/Person"><span itemprop="name">Jane Doe</span></div>

Values

  • itemscope

    Because itemscope is a boolean attribute, it doesn't have a list of "values" in the traditional sense (like the type attribute for an input). However, there are three valid ways to write it in your HTML:

    Syntax Type Code Example Note
    Short / Preferred <div itemscope> The most common and modern way to write it.
    Empty String <div itemscope=""> Valid, but rarely used.
    Attribute Name <div itemscope="itemscope"> Common in XHTML or legacy systems that require value pairs.

Example

<div itemscope itemtype="https://schema.org/Product">
<h2 itemprop="name">Chocolate Bar</h2>
<p itemprop="description">Delicious dark chocolate with almonds.</p>
<p>Brand: <span itemprop="brand">Sweet Co.</span></p>
<p>Price: $<span itemprop="price">2.50</span></p>

<!-- Nested item: manufacturer -->
<div itemscope itemprop="manufacturer" itemtype="https://schema.org/Organization">
<p>Manufacturer: <span itemprop="name">Sweet Co. Ltd</span></p>
<p>Website: <a href="https://www.example.com" itemprop="url">sweetco.com</a></p>
</div>
</div>

Browser Support

The following information will show you the current browser support for the HTML itemscope global attribute. Hover over a browser icon to see the version that first introduced support for this HTML global attribute.

This global attribute is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 27th December 2025

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!