Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When using HTML5 Microdata, should the 'itemscope' and 'itemtype' always be used on the same element?

I'm trying to understand the reason behind the existence of two attributes instead of just making the element holding the 'itemtype' the one that wraps the scope for the item.

Is it valid to have 'itemtype' attribute on one element and 'itemscope' attribute in some other? like this:

<section itemtype="http://data-vocabulary.org/Person">
    <div itemscope>
        <span itemprop="name">Alonso Torres</span>
    </div>
</section>

If this case is not valid then why the existence of the 'itemscope' attribute at all? Why the spec didn't come up with the idea of making the element holding the 'itemtype' attribute to be the one which sets the scope. That would have make sense for me.

like image 621
alonso.torres Avatar asked Feb 25 '11 23:02

alonso.torres


2 Answers

You're right, the itemscope attribute seems redundant. Someone else pointed this out on the W3C's HTML mailing list: http://lists.w3.org/Archives/Public/public-html-bugzilla/2011Jan/0517.html

The answer ( http://lists.w3.org/Archives/Public/public-html-bugzilla/2011Jan/0523.html ) was that:

The HTML spec editor did user-testing of the feature earlier, and if I recall correctly, several of the test subjects found it much easier if there was an explicit indicator of the container, rather than it being implicit due to the type.

In other words, it's better for attributes to have a single clear definition than multiple implied definitions. Not sure I agree but that's the official view.

like image 85
tagawa Avatar answered Oct 18 '22 13:10

tagawa


itemscope is mandatory if itemtype is used on the same element

The example you show is invalid. The spec has been updated to include this:

The itemtype attribute must not be specified on elements that do not have an itemscope attribute specified.

Here, "must not" is to interpreted as in RFC2119: "the definition is an absolute prohibition of the specification".

like image 33
Ruben Verborgh Avatar answered Oct 18 '22 15:10

Ruben Verborgh