W3C home > Mailing lists > Public > public-vocabs@w3.org > December 2011

Re: Nested Items in <HEAD> Element

From: Stéphane Corlosquet <scorlosquet@gmail.com>
Date: Wed, 21 Dec 2011 16:11:57 -0500
Message-ID: <CAGR+nnEi_Z2DriSo1Fqu4CkL8UW2MH_fANuVCvkKT8xN-GhutQ@mail.gmail.com>
To: "Sandhaus, Evan" <sandhes@nytimes.com>
Cc: public-vocabs <public-vocabs@w3.org>
Hi Evan,

On Wed, Dec 21, 2011 at 3:06 PM, Sandhaus, Evan <sandhes@nytimes.com> wrote:

> I am currently advising a number of teams on the implementation of
> Schema.org markup and I've encountered an issue with nested metadata in
> the <HEAD> element.
> Suppose you have a 'NewsArticle' document to which you have added an
> 'itemscope' to the <HTML> element.  Lets further suppose that you want to
> add some non-visible metadata to the <head> element, say the word count.
>  To do this you'd code up something like:
> <html itemscope itemtype='http://schema.org/NewsArticle">
> <head>
> <meta itemprop="wordCount" content="1138"/>
>  ...
> So far so good, but now suppose we want to add another bit of non-visible
> metadata to the <head>, but this time we want to add a 'Person' object.
> This is where the problem comes in.  Inserting a 'Person' object requires
> that we nest tags and  it isn't legal in HTML to nest <meta> tags.   Only a
>  few tags are legal in the scope of <HEAD>.   These tags are <TITLE>,
> <BASE>, <LINK>, <META>, and <STYLE>.  The problem with this is that none of
> these tags are permitted to have child tags and you can't express that a '
> http://schema.org/NewsItem' object is 'about' a 'http://schema.org/Person'without nesting tags.    In HTML 4 but not HTML 5 the <OBJECT> element is
> legal in the <HEAD>.
> So what can I do?  Is there any valid HTML 5 way to express the following
> (where nestable is the hypothetical name of an element that doesn't make
> this illegal )?
> <html itemscope itemtype='http://schema.org/NewsArticle">
> <head>
> <meta itemprop="wordCount" content="1138"/>
> <nestable itemscope itemtype="http://schema.org/Person">
>  <meta itemprop="name" content="Evan Sandhaus"/>
> </nestable>
>        ....
> </head>
> ...
> </html>
> If it is not possible to do this, how would you suggest I proceed?

The same topic came up during the mixer ater the schema.org workshop last
September, where we came to the same conclusion as yours. You'd have to
place your markup in <body> if you want to take advantage of the nested
elements (possibly as a hidden snippet). What you could do in <head> is use
a flat list of elements, where each element refer to one of the objects you
talk about. In RDFa, assuming you defined @vocab="http://schema.org/" in
head or html, it would look like:

<meta about="#article" typeof="NewsArticle" />
<meta about="#article" property="wordCount" content="1138"/>
<meta about="#article" property="version" content="1.1"/>
<meta about="#person" typeof="Person" />
<meta about="#person" property="name" content="John"/>

you could achieve similar results in microdata with @itemref, though the
HTML wouldn't look as linear/consistent. The @itemscope element for each
object would have to list all the other elements containing a property
defining that  object. I don't have access to the microdata testing tool
from here, so can't guarantee the snippet below works, but this is the idea:

<meta itemscope itemtype='http://schema.org/NewsArticle"
itemref="article-p1 article-p2">
<meta id="article-p1" property="wordCount" content="1138">
<meta id="article-p2" property="wordCount" content="1138">
<meta itemscope itemtype='http://schema.org/Person" itemref="person-p1">
<meta id="person-p1" property="name" content="John">

(make sure to use unique @id which don't conflict with other elements in
the body)


> Thanks!
> ~Evan
Received on Wednesday, 21 December 2011 21:12:35 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 22 May 2012 06:48:58 GMT