Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rel="canonical" html5 unable to validate

Should the link attribute rel="canonical" validate against html5?

It is the first time I am using this and I am getting the following validation errors:

"Bad value canonical for attribute rel on element link: Keyword canonical is not registered."

It kind of suggests it shouldnt although I cant find any concrete documentation on this.

Edit - Here is the line that is throwing the validator off:

<link rel="canonical" href="http://dev.local/" />

I have tried it with and without the closing slash

like image 718
David Avatar asked Feb 24 '23 00:02

David


2 Answers

Validator is marking canonical invalid because canonical is a recent addition (as Gutmann pointed out) and the validation tool does not update real time. The W3C tells us why canonical is on the Micorformats wiki but does not validate. It is because the updates of wiki data in the validator are manual.

You will see this in the validation reporting: "A whitespace-separated list of link types listed as allowed on in the HTML specification or listed as an allowed on on the Microformats wiki without duplicate keywords in the list. Note that updates of the wiki data in the validator are manual and do not happen in real time"

This will validate on their next manual update.

like image 109
Nick Avatar answered Feb 26 '23 21:02

Nick


There is no definition for the canonical rel in the HTML5 spec, but it does also say that:

The rel attribute has no default value. If the attribute is omitted or if none of the values in the attribute are recognized by the user agent, then the document has no particular relationship with the destination resource other than there being a hyperlink between the two.

So, it's not technically conforming HTML5, but it will simply be ignored by UAs which don't understand it.

like image 43
Gareth Avatar answered Feb 26 '23 20:02

Gareth