Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'itemprop' and 'rel' attributes on same element

Is it valid to use the itemprop attribute and the rel attribute on the same element?

The example from Google’s Site Name documentation contains

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

which gives this error in https://validator.w3.org/nu/:

Attribute rel not allowed on element link at this point.

like image 362
unor Avatar asked Jul 24 '15 23:07

unor


1 Answers

It depends on the specification.

Microdata, where the itemprop attribute is coming from, is defined by WHATWG’s HTML as well as by W3C’s HTML Microdata.

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.

For the a element and the area element:

  • both specifications allow to use the attributes itemprop and rel together

For the link element:

  • WHATWG: it’s disallowed to use the attributes together

    link element:

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

  • W3C: it’s allowed to use the attributes together

    Content models:

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

like image 107
unor Avatar answered Sep 20 '22 12:09

unor