HTML5 what is the itemscope attribute and what does it do in laymans terms?

前端 未结 2 1082
南笙
南笙 2021-01-30 02:23

I just wanted to know what is the HTML5 itemscope attribute used for basically?

2条回答
  •  后悔当初
    2021-01-30 02:37

    The [itemscope] attribute is a boolean attribute to define the scope of the metadata contained within the element.

    It's defined in the HTML5 Microdata API:

    Every HTML element may have an itemscope attribute specified. The itemscope attribute is a boolean attribute.

    An element with the itemscope attribute specified creates a new item, a group of name-value pairs.

    In other words, it's a way of associating metadata with a particular DOM node.

    This is used by the Schema.org API to associate data for search engines and social networks. Google+ uses schema as the way to provide titles, thumbnails, and descriptions for pages shared by users.


    It should also be noted that [itemscope] and [itemprop] are compatible with Facebook's Open Graph Protocol when providing meta data for a webpage. The same metadata can be listed for search engines, Facbook, and Google+ in a single set of elements rather than having to list the same information more than once:

    
      
        An Example Title
        
        
        
        
        
      
      
        ...content...
      
    
    

    Note that in the example, [itemscope] was added to the element. This means that any [itemprop] attributes in the and are part of the WebPage item.

提交回复
热议问题