Is 'itemprop' without parent 'itemscope' valid? Does it create an item?

前端 未结 2 1168
误落风尘
误落风尘 2020-12-21 04:03

In the following example, Microdata’s itemref attribute is used to add the email property to the Person item (both from a fictive Micr

相关标签:
2条回答
  • 2020-12-21 04:18
    1. Is this valid Microdata?
      • Yes it is!
    2. Does an itemprop without an itemscope parent create an item?
      • No it doesn't!

    An item is created by the itemscope attribute. With or with out properties, it is an item ones you declared it as an item. An itemprop declares the property of an item, it will never create it. It is still valid html to have the itemprop attribute declared on "orphans" sense there is no dependencies in html on attributes like does on elements.

    http://www.w3.org/TR/2011/WD-microdata-20110405/#the-basic-syntax 9:th example describes the topic bit.

    I work with these type of extractions a lot. The way I designed the software is to look for the root of every item, that's where the scope is declared. I then extend the scope if a reference is declared. I never look for properties outside the scope sense it's irrelevant.

    0 讨论(0)
  • 2020-12-21 04:38

    The spec requirement is just that the itemprop is used in at least one item. There's no suggestion that I can see that being referenced by an itemref does not constitute a usage, nor that the itemprop is copied, and that it is the copy which is used not the original. So I think the spec requirements are fulfilled, and the microdata is valid.

    Moreover, consider the intent of the spec. The underlying idea is that an itemprop that is not used by any item is pointless - a waste of typing - an therefore must be an authoring mistake. That is sufficient for mark-up to be considered invalid. Since that is not the case here, there is no justification for making such a construct invalid.

    0 讨论(0)
提交回复
热议问题