'itemprop'和'rel'属性在同一个元素上 [英] 'itemprop' and 'rel' attributes on same element

查看:257
本文介绍了'itemprop'和'rel'属性在同一个元素上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 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 and rel together

对于链接元素:


  • WHATWG: 禁止一起使用这些属性

link 元素


link 元素必须具有 rel 属性或 itemprop 属性,但不是两者。

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


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

    内容模型


    如果链接元素已包含一个 itemprop 属性, rel 属性可能会被省略。

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


  • 这篇关于'itemprop'和'rel'属性在同一个元素上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆