隐藏'content'属性中的Microdata属性值? [英] Hide Microdata property value in 'content' attribute?
问题描述
我在最近添加了Schema.org标记的网站上工作,但我认为它被错误地使用了。
< span itemprop =name>跨度>
我们的网站通过以下方式实施:
< pre class =lang-html prettyprint-override>
< span itemprop =namecontent =Generic Name Here>< / span>
我们的第二种方式是否被认为是隐藏的?我们将数据显示给用户,但是在不同的地方,它没有用 itemprop
标记。
在HTML5中, content
属性 只允许 meta
元素。 并未将其定义为全局属性。但是RDFa 扩展 HTML以使 content
全局属性。
根据您的示例,您正在使用Microdata。所以你不应该在 span
中使用 content
属性。
Microdata定义了一种添加名称 - 值对的方法,而不必标记可见内容:Microdata body $>中扩展 HTML5以允许 meta
和 link
c $ c>(将来,这将直接在HTML5规范中定义;请参阅 link
和 meta
在HTML 5.1编辑器草案中)。
所以不是
< span itemprop =namecontent =Generic Name Here>< / span>
您应该使用
< meta itemprop =namecontent =Generic Name Here/>
对于schema.org,请参阅遗漏/隐含信息:使用 meta
标签和 content
:
这项技术应该谨慎使用。只有使用
meta
和content
才能获得无法标记的信息。
I work on a website that recently had Schema.org markup added to it, but I think it is being used wrong.
Schema.org gives the example of
<span itemprop="name">Generic Name Here</span>
Our website implemented it in the following way
<span itemprop="name" content="Generic Name Here"></span>
Is the second way, our way, considered cloaking? We display the data to the user but at a different point and it is not marked up with itemprop
.
In HTML5, the content
attribute is only allowed on the meta
element. Microdata doesn’t define it as global attribute either. But RDFa extends HTML to make content
a global attribute.
According to your example, you are using Microdata. So you shouldn’t use the content
attribute for span
.
Microdata defines a way to add name-value pairs without having to mark up visible content: Microdata extends HTML5 to allow meta
and link
in body
(in the future, this will be defined in the HTML5 spec directly; see the "Contexts in which this element can be used" for link
and meta
in the HTML 5.1 Editor’s Draft).
So instead of
<span itemprop="name" content="Generic Name Here"></span>
you should use
<meta itemprop="name" content="Generic Name Here" />
For schema.org, see Missing/implicit information: use the meta
tag with content
:
This technique should be used sparingly. Only use
meta
withcontent
for information that cannot otherwise be marked up.
这篇关于隐藏'content'属性中的Microdata属性值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!