Hailwood
Hailwood

Reputation: 92581

The "rel" attribute

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)

Upvotes: 4

Views: 3773

Answers (4)

Ropstah
Ropstah

Reputation: 17794

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

Upvotes: 13

dianovich
dianovich

Reputation: 2287

The problem you'll have is that search engines do make use of the rel attribute. While SEO is not my focus, we often have SEO firms telling us to stick a rel in here and a rel in there... usually rel="nofollow" to prevent giving weight to certain external links.

Upvotes: 1

Alistair Laing
Alistair Laing

Reputation: 973

You could just create your own custom attributes but make sure that you name it currently as to not conflict with other js libraries that you may use.

Upvotes: -1

Quentin
Quentin

Reputation: 943510

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.

Upvotes: 11

Related Questions