Open In App

HTML itemtype Attribute

Improve
Improve
Like Article
Like
Save
Share
Report

The itemtype attribute specifies the URL but the URLs are not connected with any resources rather they are used by browsers to act as the identifiers. The itemtype attribute can only be specified on those elements that contain the itemscope attribute otherwise it will not execute properly. The types of items used in the itemtype URL must be of those types that are defined in specifications provided by schema.org. Some of the browsers that refer to microdata on schema.org look for specific resources on the webpage and there these itemtype and itemscope attributes are mostly used. The itemtype attribute should have a value containing the unordered set of unique tokens & those are case-sensitive, specifying each contains the absolute & valid URL. The value of the attribute should contain a minimum of 1 token.

Syntax:

<div itemscope itemtype="URL">
    <span itemprop="item1">item name</span>
    <span itemprop="item2">item name</span>
</div>

Note: The itemtype must be a URL or you can also use URN (Uniform Resource Name) as we have used in the below example.

Attribute Value: The attribute must contain a valid URL consisting of no leading & trailing whitespaces.

Supported tags:

Example 1: This example describes the implementation of the itemtype attribute in HTML.

HTML




<!DOCTYPE html>
<html>
 
<head>
    <title>HTML itemtype attribute</title>
</head>
 
<body>
    <h1>GeeksforGeeks</h1>
    <h4>Tutorials and Courses</h4>
    <div itemscope itemtype=
        "http://geeksforgeeks.org">
        <span itemprop="description">
            GeeksforGeeks is a portal for geeks.
            It has tutorials on various topics.
        </span>
        <br>
        Course: <span itemprop="course">Java</span>
        <br>
        Tutorial: <span itemprop="tutorial">C++</span>
        <br>
    </div>
</body>
 
</html>


Output:

HTML itemtype Attribute

Example 2: This example describes the itemtype attribute, by specifying the itemprop that describes the property of an item.

HTML




<!DOCTYPE html>
<html>
 
<head>
    <title>HTML itemtype attribute</title>
</head>
 
<body>
    <h1>GeeksforGeeks</h1>
    <h4>Paid Courses</h4>
    <div itemscope itemtype=
        "http://geeksforgeeks.org">
        <span itemprop="product" itemtype=
            "http://geeksforgeeks.org/product">
            GeeksforGeeks is a portal for geeks.
        </span><br><br>
            Course:
            <span itemprop="course">
                Data Structures and Algorithms
            </span><br>
            Tutorial:
            <span itemprop="tutorial">
                Core Java
            </span>
    </div>
</body>
 
</html>


Output:

HTML itemtype Attribute

Supported Browser: The browser that supports the itemtype attribute are listed below:

  • Google Chrome
  • Microsoft Edge 12 and above
  • Firefox
  • Opera
  • Safari


Last Updated : 24 Aug, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads