隐藏'content'属性中的Microdata属性值?

编程入门 行业动态 更新时间:2024-10-24 00:18:15
本文介绍了隐藏'content'属性中的Microdata属性值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在最近添加了Schema标记的网站上工作,但我认为它被错误地使用了。

给出以下示例

< span itemprop =name>跨度>

我们的网站通过以下方式实施:

< 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,请参阅遗漏/隐含信息:使用 meta 标签和 content :

这项技术应该谨慎使用。只有使用 meta 和 content 才能获得无法标记的信息。

I work on a website that recently had Schema markup added to it, but I think it is being used wrong.

Schema 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, see Missing/implicit information: use the meta tag with content:

This technique should be used sparingly. Only use meta with content for information that cannot otherwise be marked up.

更多推荐

隐藏'content'属性中的Microdata属性值?

本文发布于:2023-11-02 08:14:33,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:属性   content   Microdata

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!