Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The "rel" attribute

Tags:

html

rel

I have noticed that the "rel" attribute is not used at all by browsers, does this make it an ideal place to store additional information for javascript (eg a delete ajax request could read the id from rel)

like image 277
Hailwood Avatar asked Nov 29 '22 10:11

Hailwood


2 Answers

I have noticed that the "rel" attribute is not used at all by browsers

You noticed wrong. Browsers do make use of it (e.g. some browsers have a keyboard shortcut to go to the next page and can use the rel attribute to determine that that is). Search engines also make use of it (e.g. nofollow).

does this make it an ideal place to store additional information for javascript

No. Attributes have specified purposes. Don't assume that they aren't going to be used for that.

like image 27
Quentin Avatar answered Dec 10 '22 23:12

Quentin


I'm assuming you are looking for a way to store custom data you can use in javascript. I that case:

Storing custom data can be done using data- attributes (see here).

<a href="somelink.html" data-id="5">Link 5</a>

Alternatively/additionally you could use jQuery Metadata

like image 134
Ropstah Avatar answered Dec 11 '22 00:12

Ropstah