HTML Guide
When the itemtype
attribute is specified on an HTML element, the boolean attribute itemscope
must also be present in that element.
Here’s an example of how to use the itemscope
attribute with the itemtype
attribute:
<div itemscope itemtype="http://schema.org/Person">
<p><span itemprop="name">Liza Jane</span></p>
<p><span itemprop="email">liza.jane@example.com</span></p>
</div>
In this example, the itemscope
attribute is used to indicate that the div
element is a microdata item, and the itemtype
attribute is used to specify that the type of this item is http://schema.org/Person.
If you don’t need to specify a type for the data represented by the HTML element, you can simply remove the itemtype
attribute. For example:
<div itemscope>
<p><span itemprop="name">John Doe</span></p>
<p><span itemprop="email">john.doe@example.com</span></p>
</div>
Learn more:
Related W3C validator issues
The itemscope attribute is a boolean attribute in HTML5, which means it does not take any values. Adding any value (such as true or false) will cause an error. When using boolean attributes, they should either be present or absent. If an attribute like itemscope is present, it is considered true.
Here’s how to correct the error:
Incorrect Usage:
<div itemscope="true">
Correct Usage:
<div itemscope>
Explanation:
- Simply including the itemscope attribute without any value is the correct way to use it.
- If you don’t want to use the itemscope attribute, just remove it from the tag.
An itemprop attribute has been found in the document, but it cannot be associated to any item. Most probable cause is the lack of an itemscope attribute defining an item.
Microdata allows nested groups of properties, which must be scoped to the item they belong to, as in this example:
<div itemscope>
<p>My name is <span itemprop="name">Liza</span> and I'm <span itemprop="age">48</span> years old.</p>
</div>