English 中文(简体)
HTML5 - Microdata
  • 时间:2024-11-03

HTML5 - Microdata


Previous Page Next Page  

Microdata is a standardized way to provide additional semantics in your web pages.

Microdata lets you define your own customized elements and start embedding custom properties in your web pages. At a high level, microdata consists of a group of name-value pairs.

The groups are called items, and each name-value pair is a property. Items and properties are represented by regular elements.

Example

    To create an item, the itemscope attribute is used.

    To add a property to an item, the itemprop attribute is used on one of the item s descendants.

Here there are two items, each of which has the property "name" −

<html>
   <body>
      
      <span itemscope>
         <p>My name is <span itemprop = "name">Zara</span>.</p>
      </span>
      
      <span itemscope>
         <p>My name is <span itemprop = "name">Nuha</span>.</p>
      </span>
      
   </body>
</html>

It will produce the following result −