'itemprop'和'rel'属性在同一个元素上 [英] 'itemprop' and 'rel' attributes on same element
问题描述
使用 itemprop
属性和 rel
属性是否有效相同元素?
Is it valid to use the itemprop
attribute and the rel
attribute on the same element?
来自 Google的网站名称文档包含
<link rel="canonical" href="https://example.com/" itemprop="url">
在 https://validator.w3.org/nu/ :
属性
rel
此时元素链接
上不允许。
推荐答案
这取决于规格。
微数据,其中 itemprop
属性来自,是由WHATWG的 HTML 定义,以及 W3C的 HTML微数据 。
Microdata, where the itemprop
attribute is coming from, is defined by WHATWG’s HTML as well as by W3C’s HTML Microdata.
WHATWG版本是一个没有快照的生活标准(所以事情可能会改变;我的报价是2015-07-25), W3C版本目前只有 工作组备注从2013年开始,没有推荐。
The WHATWG version is a living standard without snapshots (so things might change; my quotes are from 2015-07-25), the W3C version is currently only a Working Group Note from 2013, no Recommendation.
对于 a
元素和区域
元素:
- 两个规范都允许使用属性
itemprop
和rel
一起
- both specifications allow to use the attributes
itemprop
andrel
together
对于链接
元素:
-
WHATWG: 禁止一起使用这些属性
link
元素必须具有rel
属性或itemprop
属性,但不是两者。
A
link
element must have either arel
attribute or anitemprop
attribute, but not both.
W3C: 允许一起使用这些属性
内容模型:
如果
链接
元素已包含一个itemprop
属性,rel
属性可能会被省略。
If a
link
element has anitemprop
attribute, therel
attribute may be omitted.
这篇关于'itemprop'和'rel'属性在同一个元素上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!