我只是想知道基本上使用的HTML5 itemscope属性是什么?
发布于 2018-04-03 13:17:12
该[itemscope]
属性是一个布尔属性,用于定义元素中包含的元数据的范围。
它在HTML5 Microdata API中定义:
每个HTML元素可能都有一个
itemscope
指定的属性。该itemscope
属性是一个布尔属性。 具有itemscope
指定属性的元素将创建一个新项目,即一组名称 - 值对。
换句话说,它是一种将元数据与特定DOM节点关联的方式。
这被Schema.org API用来关联搜索引擎和社交网络的数据。Google+使用架构作为为用户共享的页面提供标题,缩略图和说明的方式。
当为网页提供元数据时,还应该注意[itemscope]
并[itemprop]
与Facebook的开放图协议兼容。搜索引擎,Facbook和Google+可以在一组<meta>
元素中列出相同的元数据,而不必多次列出相同的信息:
<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>
元素中。这意味着,任何[itemprop]
在属性<head>
和<body>
是部分WebPage
项目。
发布于 2018-04-03 14:19:59
搜索引擎包括Bing,Google和Yahoo! 现在正在使用Itemscope和朋友来识别网页中的语义数据。
https://stackoverflow.com/questions/-100003774
复制相似问题