Anchor rel attribute

Definition and usage

rel Attribute sets or returns the link's rel attribute Value.

rel The attribute specifies the relationship between the current document and the linked document.

Example

Example 1

Return the rel attribute value of the link:

var x = document.getElementById("myAnchor").rel;

Try it yourself

Example 2

Set the value of the rel attribute to "nofollow":

document.getElementById("myAnchor").rel = "nofollow";

Try it yourself

Syntax

Return the rel attribute:

anchorObject.rel

Set the rel attribute:

anchorObject.rel = "value"

Attribute value

Value Description
alternate An alternative version of the document (such as print pages, translations, or mirrors).
author The author of the file.
bookmark Related documents.
help Help documentation.
licence The copyright information of the document.
next The next document in the collection.
nofollow Google uses "nofollow" to specify that Google search spiders should not follow the link (mainly used for paid links).
noreferrer The browser should not send the HTTP Referer header if the user clicks on a hyperlink.
prefetch Specifies that the target document should be cached.
prev The previous document in the collection.
search The search tool of the document.
tag The tag (keyword) of the current document.

Technical Details

Return Value: A string value indicating the relationship between the current document and linked documents.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support

Related Pages

HTML Reference Manual:HTML <a> rel Attribute