2014-12-04 47 views
0

我想知道如果像下面这样是很好..是否可以将页面的元描述用作微数据?

<!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

这是行不通的。

itemref属性用于引用Microdata属性,但引用的meta元素不具有itemprop属性。

而且您不能将itemprop属性添加到meta元素if it has a name attribute

如果你不希望有这样的描述中可见的页面上,你可以

  • 添加meta元素在head,使用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

+0

谢谢您的回答,我希望能找到不涉及添加描述两次的解决方案。猜猜这是不可能的。别担心 – shunryu111 2014-12-09 09:49:19

相关问题