HTML5什么是itemscope属性以及它在外行术语中的作用是什么? [英] HTML5 what is the itemscope attribute and what does it do in laymans terms?
问题描述
我只是想知道什么是基本上使用的HTML5 itemscope属性?
I just wanted to know what is the HTML5 itemscope attribute used for basically?
推荐答案
[itemscope]
属性是一个布尔属性,用于定义元素中包含的元数据的范围。
The [itemscope]
attribute is a boolean attribute to define the scope of the metadata contained within the element.
它在 HTML5 Microdata API:
每个HTML元素都可能指定了
itemscope
属性。itemscope
属性是布尔属性。
Every HTML element may have an
itemscope
attribute specified. Theitemscope
attribute is a boolean attribute.
itemscope $的元素c $ c>指定的属性会创建一个新的项,一组名称 - 值对。
An element with the itemscope
attribute specified creates a new item, a group of name-value pairs.
In换句话说,它是一种将元数据与特定DOM节点相关联的方式。
In other words, it's a way of associating metadata with a particular DOM node.
这是由 Schema.org 用于关联搜索引擎和社交网络数据的API。 Google+使用架构作为为用户分享的网页提供标题,缩略图和说明的方式。
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.
还应注意 [itemscope]
和 [itemprop]
与Facebook的开放图谱协议兼容为网页提供元数据。可以在一组< meta>
元素中为搜索引擎,Facbook和Google+列出相同的元数据,而不必多次列出相同的信息:
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 <meta>
elements rather than having to list the same information more than once:
<html itemscope itemtype="http://schema.org/WebPage" xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
<title>An Example Title</title>
<meta content="An Example Title" itemprop="name" property="og:title" />
<meta content="Lorem ipsum dolor sit amet" itemprop="description" name="description" property="og:description" />
<meta content="http://www.example.com/image.jpg" itemprop="image" property="og:image" />
<meta content="http://www.example.com/permalink" itemprop="url" property="og:url" />
<link rel="canonical" href="http://www.example.com/permalink" />
</head>
<body>
...content...
</body>
</html>
请注意,在示例中, [itemscope]
已添加到< html>
元素中。这意味着< head>
和< body>中的任何
是 [itemprop]
属性; WebPage
项目的一部分。
Note that in the example, [itemscope]
was added to the <html>
element. This means that any [itemprop]
attributes in the <head>
and <body>
are part of the WebPage
item.
这篇关于HTML5什么是itemscope属性以及它在外行术语中的作用是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!