HTML5 Microdata: Range Content?

I read the HTML5 specification , specification of microdata and specifications WHATWG HTML5 (microdata) . They are well written and easy to understand.

But now I read the schema.org spec spec 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 to the JSON version) the values ​​of these microdata properties are the values ​​of the content

element attributes span

. (Of course, if the attribute is content

missing, the value is instead of the textContents

element span

.)

But I cannot find support for this practice in the HTML and microdata specs. In fact, I can't even find any evidence that the attribute is content

on elements span

at all!

  • The microdata spec doesn't say anything about the attribute span

    content

    when it gives rules for values . [Unless the textContent element is overridden by an attribute content

    , but I can't find any support for that.]

  • Even the complete WHATWG HTML5 + microdata specification does not support the assertion of having an attribute content

    on span

    (see span

    element
    and Global Attributes ).

So my guess is that the schema.org example does not meet the requirements. But is that also wrong? If not, where is this practice from, and how is it accepted?

+3


source to share


2 answers


Yes, it’s wrong. Neither Microdata nor HTML5 define an attribute content

for an element span

.

Several people wanted to use it, see for example the code in these questions:

I'm not sure where exactly this confusion comes from.



(It doesn't help that Google's Structured Data Testing tool incorrectly uses attribute content

instead of element content, but at least all other Microdata parsers are correct.)

Perhaps some people are confused because RDFa (but not Microdata) defines and allows content

an attribute
for span

. See HTML + RDFas HTML5 Syntax Extensions :

For avoidance of doubt, all elements in HTML5 content model allowed RDFa following attributes: @vocab

, @typeof

, @property

, @resource

, @prefix

, @content

, @about

, @rel

, @rev

, @datatype

and @inlist

.

+6


source


(Sorry, I don't have enough reputation to post a comment.)



We are at the end of 2017. Anyway, MDD webdocs ( https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/itemprop ) and schema docs ( http://schema.org/telephone ) still suggest using the attribute content

on span

using microdata. No html5 validator would agree with this of course.

+2


source







All Articles