是否可以将页面的元描述用作微数据?

时间:2014-12-04 11:18:07

标签: html5 semantic-markup microdata

我想知道下面的内容是否正常......

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Microdata Example</title>
    <meta id="site-description" name="description" content="description text here">
</head>
<body itemscope itemref="site-description" itemtype="http://schema.org/Organization">
    <h1 itemprop="name">Foo</h1>
    <img itemprop="image" src="bar.jpg">
</body>
</html>

1 个答案:

答案 0 :(得分:1)

这不起作用。

itemref属性用于引用微数据属性,但引用的meta元素没有itemprop属性。

并且您无法向itemprop元素if it has a name attribute添加meta属性。

如果您不希望在页面上显示此说明,则可以

  • 使用metahead中添加itemref元素:

    <head>
        <meta name="description" content="description text here">
        <meta id="site-description" itemprop="description" content="description text here">
    </head>
    <body itemscope itemref="site-description" itemtype="http://schema.org/Organization">
    </body>
    
  • meta中添加body元素,而不是使用itemref

    <head>
        <meta name="description" content="description text here">
    </head>
    <body itemscope itemtype="http://schema.org/Organization">
        <meta itemprop="description" content="description text here">
    </body>
    

(假设您要使用Schema.org的description property。)