Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
581 views
in Technique[技术] by (71.8m points)

html - Hide Microdata property value in 'content' attribute?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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 with content for information that cannot otherwise be marked up.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...