THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Anchor rel Property

Anchor Object Reference Anchor Object

Example

Return the value of the rel attribute of a link:

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

The result of x will be:

nofollow
Try it yourself »

Definition and Usage

The rel property sets or returns the value of the rel attribute of a link.

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


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The rel property is supported in all major browsers.

Note: Browsers do not use this property in any way. However, search engines can use this property to get more information about a link.


Syntax

Return the rel property:

anchorObject.rel

Set the rel property:

anchorObject.rel="value"

Property Values

Value Description
alternate An alternate version of the document (i.e. print page, translated or mirror)
author The author of the document
bookmark A related document
help A help document
licence Copyright information for the document
next The next document in a selection
nofollow "nofollow" is used by Google, to specify that the Google search spider should not follow that link (mostly used for paid links)
noreferrer Specifies that the browser should not send a HTTP referer header if the user follows the hyperlink
prefetch Specifies that the target document should be cached
prev The previous document in a selection
search A search tool for the document
tag A tag (keyword) for the current document

Technical Details

Return Value: A String, representing the relationship between the current document and the linked document

More Examples

Example

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

document.getElementById("myAnchor").rel = "nofollow";
Try it yourself »

Related Pages

HTML reference: HTML <a> rel attribute


Anchor Object Reference Anchor Object