Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the schema.org documentation partly invalid?

I'm writing HTML/CSS/JS for about two years now and just decided to take more focus on to enhance my markup by using microdata/RDF.

Through further investigations and by looking up how this thing is already handled in the wild I came across YouTube and saw they're using meta tags within a div-block to describe their videos and found it to be weird since I never used meta tags beside within the head-section of a document.

The div-block had an itemtype to declare the scheme it's using so I checked the given page (schema.org) and found by digging in their docs the following part:

3c. Missing/implicit information: use the meta tag with content

Sometimes, a web page has information that would be valuable to mark up, but the information can't be marked up because of the way it appears on the page. [...]

In these cases, use the meta tag along with the content attribute to specify the information. Consider this example—the image shows users a 4 out of 5 star rating:

<div itemscope itemtype="http://schema.org/Offer">
  <span itemprop="name">Blend-O-Matic</span>
  <span itemprop="price">$19.95</span>
  <img src="four-stars.jpg" />
  Based on 25 user ratings
</div>

Here is the example again with the rating information marked up.

<div itemscope itemtype="http://schema.org/Offer">
  <span itemprop="name">Blend-O-Matic</span>
  <span itemprop="price">$19.95</span>
  <div itemprop="reviews" itemscope itemtype="http://schema.org/AggregateRating">
    <img src="four-stars.jpg" />
    <meta itemprop="ratingValue" content="4" />
    <meta itemprop="bestRating" content="5" />
    Based on <span itemprop="ratingCount">25</span> user ratings
  </div>
</div>

Source: http://schema.org/docs/gs.html#advanced_missing

Now it seems like best practise to (sometimes) add microdata that way but it still felt strange to me to use meta out of the head-block so I checked the w3 about meta tags and realized where that feeling came from.

4.2.5 The meta element

...

Contexts in which this element can be used:

  • If the charset attribute is present, or if the element's http-equiv attribute is in the Encoding declaration state: in a head element.
  • If the http-equiv attribute is present but not in the Encoding declaration state: in a head element.
  • If the http-equiv attribute is present but not in the Encoding declaration state: in a noscript element that is a child of a head element.
  • If the name attribute is present: where metadata content is expected.

...

Exactly one of the name, http-equiv, charset attributes must be specified.

If either name or http-equiv is specified, then the content attribute must also be specified. Otherwise, it must be omitted.

Source: http://www.w3.org/TR/html5/document-metadata.html#the-meta-element

Now I don't know what to think about that since the documentation given by schema.org practically ignores the w3 recommendation.

So I'm asking the more experienced guys for an answer to this before I actually start doing it wrong.

Greets JD.

like image 879
John Doesen Avatar asked Sep 15 '13 07:09

John Doesen


1 Answers

Yeah. This is a bit complicated. Are you sitting comfortably? Then I'll begin...

Microdata first appeared in what's now called the HTML Living standard as an integral chapter of that. This is the HTML spec produced by WHATWG. At the time the W3C HTML5 draft automatically took the same changes, so Microdata appeared in that standard too. However the people at the W3C felt that it conflicted and competed with their own existing standard RDFa on which they had been working for some time. They felt that having Microdata in the main HTML5 standard document, while RDFa was separate was unfair, and so Microdata was moved at the W3C to a separate standard

Both the HTML living standard (still) and the W3C Microdata standard (until recently) specifically state that the <meta> element is valid in <body> if and only if it contains a itemprop attribute and a content attribute, and none of the other <meta> element specific attributes. (e.g. it must not contain http-equiv or name attributes, but id and class are OK.)

More recently however, it has been decided that the validity requirement would be better in the main W3C HTML spec rather that the microdata spec. So the actual requirements have been removed from the microdata spec, although there are still a couple of examples of <meta> elements being used in <body>.

This all happened after the HTML5 spec was fixed - effectively only clarifications and bug fixes can be made now - so the validity information was moved to the W3C HTML5.1 spec

That describes the validity requirement that make <meta> in <body> valid. It says (see the last bullet point):

4.2.5 The meta element

Contexts in which this element can be used:

  • If the charset attribute is present, or if the element's http-equiv attribute is in the Encoding declaration state: in a head element.
  • If the http-equiv attribute is present but not in the Encoding declaration state: in a head element.
  • If the http-equiv attribute is present but not in the Encoding declaration state: in a noscript element that is a child of a head element.
  • If the name attribute is present: where metadata content is expected.
  • If the itemprop attribute is present: where metadata content is expected.
  • If the itemprop attribute is present: where phrasing content is expected.

Note that the <link> element is also extended in a similar way.

UPDATE:

As unor notes in the comments, the changes to the "Contexts in which this element can be used:" for the meta element didn't make into the HTML 5.1 Recommendation, and they weren't restored to 5.2 or 5.3 either.

They now appear in the separate W3C Microdata Spec under Section 7.2 Content Models where point 4 says:

If the itemprop attribute is present on a link or meta element, that element is flow content and phrasing content, and may be used where phrasing content is expected.

like image 179
Alohci Avatar answered Oct 20 '22 22:10

Alohci