Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unregistered values of rel attribute in anchor tag

I used rel values in jQuery for the parametrized (#!hashbang) AJAX calls.

<a id='_qualifier' rel='telephony' href='contact.php'>contact</a>

and with jQuery:

var hashbang = "#!"+$("#_qualifier").attr('rel'); //gives desired result=>"#!telephony"

But, when I validated the page on validator.w3.org, it gave me error:

Bad value #telephony for attribute rel on element a: Keyword #telephony is not registered.

I searched around and according to the HTML5 specs here and here, the rel attribute should have the registered/pre-defined values.

  1. Is there a work around to use custom values for rel in HTML5, without failing the validation?
  2. Is it also invalid for HTML4 doctypes?
like image 635
vulcan raven Avatar asked Oct 25 '25 22:10

vulcan raven


2 Answers

You can use custom attributes:

<a href="#" data-something="telephony">...</a>

It is HTML5 compliant, but not HTML4 or xHTML. You'll access the attribute just like you did with jQuery.

You can find more informations on the HTML5 reference.

like image 88
ldiqual Avatar answered Oct 27 '25 11:10

ldiqual


Is there a work around to use custom values for rel in HTML5, without failing the validation?

The microformats page is a Wiki. If you are satisfied that you are using rel correctly and that there is no other appropriate rel value already registered, you can add you own value as a Proposed value. Instructions for doing so can be found here: http://dev.w3.org/html5/spec/links.html#other-link-types

According to the HTML5 spec, this will make your rel value valid. Of course, it may take some time before automated validators catch up with this, but that's just a technical matter.

Is it also invalid for HTML4 doctypes?

No, it isn't.

like image 37
Alohci Avatar answered Oct 27 '25 12:10

Alohci



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!