HTML5微数据:跨度内容? [英] HTML5 microdata: span content?
问题描述
我已阅读 HTML5规范 ,微数据规范以及 WHATWG HTML5(带微数据)规范。这些都写得很好,很容易理解。
但现在我读了 schema.org Book specification ,并且遇到以下片段:
< span itemprop =price含量= 6.99 > $ 6.99< /跨度>
< span itemprop =namecontent =Tolkien,J。R. R.(John Ronald Reuel)>
J. R. R. Tolkien< / span>
显然(与JSON版本相比),这些微数据属性的值是<的值code> content span
元素的属性。 (当然,如果没有 content 属性,则该值是
的
元素。) textContents
> span
但是我无法在HTML和微数据规范中找到对这种做法的支持。事实上,我甚至找不到任何证据显示 span
元素上的属性
属性!
-
微数据规范没有提及
span
content
属性,当它给出值。 [除非'元素的textContent'被content
属性覆盖,但我也找不到任何支持。] -
即使完整的WHATWG HTML5 +微数据规范也不支持声明
span $ c $上有
内容
属性c>(请参阅span
元素和全球属性)。
所以,我想schema.org的例子是不符合的。但这也是错误的吗?如果没有,这种做法是从哪里来的,它是如何被接受的?
是的,这是不对的。 Microdata和HTML5都没有为 span
元素定义内容
属性。 几个人想要使用它,例如看这些问题中的代码: (Google的结构化数据测试工具不正确地使用 也许有些人感到困惑,因为RDFa(但不是Microdata)定义并允许 为了避免疑惑,HTML5内容中的所有元素都允许使用以下RDFa属性模型: I have read the HTML5 specification, the microdata specification, and the WHATWG HTML5 (with microdata) specification. These are well written and easy to understand. But now I read the schema.org Book specification, and came across snippets like the following:
li> 内容属性对< span>有效标签>如果是的话,这是一个很好的做法?
$ b 我不确定这种混淆来自何处。 b
$ b 内容
属性而不是元素内容;但至少所有其他Microdata解析器似乎都能正确执行。)
content
属性为 span
。请参阅HTML + RDFa的扩展程序HTML5语法:
@vocab
, @typeof
, @property
, @resource
, @prefix
, @content
, @about
, @rel
, @rev
, @datatype
和 @inlist
。
<span itemprop="price" content="6.99">$6.99</span>
<span itemprop="inLanguage" content="en">English-language</span>
<span itemprop="name" content="Tolkien, J. R. R. (John Ronald Reuel)">
J. R. R. Tolkien</span>
Apparently (compare with the JSON version), the values of these microdata properties are the values of the content
attributes of the span
elements. (Of course, if there is no content
attribute, the value is instead the textContents
of the span
element.)
But I cannot find any support for this practice in the HTML and microdata specifications. In fact, I cannot even find any evidence that there is a content
attribute on span
elements at all!
The microdata specification doesn't say anything about a
span
content
attribute when it gives the rules for values. [Unless 'the element's textContent' is overridden by thecontent
attribute, but I cannot find any support for this either.]Not even the full WHATWG HTML5+microdata specification supports the claim that there is a
content
attribute onspan
(see Thespan
element and Global attributes).
So, I suppose the schema.org example is non-conforming. But is it also plain wrong? If not, where does this practice come from, and how accepted is it?
Yes, this is wrong. Neither Microdata nor HTML5 define a content
attribute for the span
element.
Several people wanted to use it, see for example the code in these questions:
- Hide Microdata property value in 'content' attribute?
- Categories for Product in schema.org?
- Is the "content" attribute valid for the <span> tag > if so is it a good practice?
- schema.org product availability tags markup
I’m not sure where exactly this confusion is coming from.
(It doesn’t help that Google’s Structured Data Testing Tool incorrectly uses the content
attribute instead of the element content; but at least all other Microdata parsers seem to do it correctly.)
Maybe some people got confused because RDFa (but not Microdata) defines and allows the content
attribute for span
. See HTML+RDFa’s Extensions to the HTML5 Syntax:
For the avoidance of doubt, the following RDFa attributes are allowed on all elements in the HTML5 content model:
@vocab
,@typeof
,@property
,@resource
,@prefix
,@content
,@about
,@rel
,@rev
,@datatype
, and@inlist
.
这篇关于HTML5微数据:跨度内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!