HTML5微数据:跨度内容? [英] HTML5 microdata: span content?

查看:94
本文介绍了HTML5微数据:跨度内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已阅读 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>(请参阅 span 元素全球属性)。




所以,我想schema.org的例子是不符合的。但这也是错误的吗?如果没有,这种做法是从哪里来的,它是如何被接受的?

是的,这是不对的。 Microdata和HTML5都没有为 span 元素定义内容属性。



几个人想要使用它,例如看这些问题中的代码:


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

  • <在schema.org中产品的类别?

  • li> 内容属性对< span>有效标签>如果是的话,这是一个很好的做法?
  • schema.org产品可用性标记标记

  • $ b 我不确定这种混淆来自何处。 b
    $ b

    (Google的结构化数据测试工具不正确地使用内容属性而不是元素内容;但至少所有其他Microdata解析器似乎都能正确执行。)



    也许有些人感到困惑,因为RDFa(但不是Microdata)定义并允许 content 属性 span 。请参阅HTML + RDFa的扩展程序HTML5语法


    为了避免疑惑,HTML5内容中的所有元素都允许使用以下RDFa属性模型: @vocab @typeof @property @resource @prefix @content @about @rel @rev @datatype @inlist



    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:

    <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 the content 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 on span (see The span 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:

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆