同一元素上的 'itemprop' 和 'rel' 属性

'itemprop' and 'rel' attributes on same element

在同一元素上使用 itemprop 属性 rel 属性是否有效?

来自 Google’s Site Name documentation 的示例包含

<link rel="canonical" href="https://example.com/" itemprop="url">

https://validator.w3.org/nu/ 中出现此错误:

Attribute rel not allowed on element link at this point.

这取决于规格。

itemprop 属性来自的微数据是 defined by WHATWG’s HTML as well as by W3C’s HTML Microdata

WHATWG 版本是没有快照的生活标准(所以事情可能会改变;我的引用来自 2015-07-25),W3C 版本目前只有 Working Group Note from 2013,没有 推荐.

对于 a 元素和 area 元素:

  • 两种规范都允许同时使用属性 itemproprel

对于 link 元素:

  • WHATWG:不允许一起使用这些属性

    link element:

    A link element must have either a rel attribute or an itemprop attribute, but not both.

  • W3C:允许一起使用属性

    Content models:

    If a link element has an itemprop attribute, the rel attribute may be omitted.