HTML DOM Anchor rel Property

The HTML DOM Anchor Rel property returns the rel attribute of a link. The rel attribute describes the association between the running document and the linked document.

Syntax

Following is the syntax to ?

  • a) Return the rel property ?

anchorObject.rel
  • b) Set the rel property &minus

anchorObject.rel = "value"

Example

Let us see an example of the HTML DOM anchor rel property ?



Example

Anchor Rel Property

Click on the button

Output

This will produce the following output ?

Click on the "Click me!" button to get the HTML DOM Anchor rel property ?

In the above example ?

We have taken an anchor tag with rel property used for specifying the type of relation to the linked document which in the above code is https://www.examplesite.com/

Anchor Rel Property

We have then created a button named "Click Me" to execute the display function ?

The display function gets the rel property of the element with id=" Anchor example" ?

function display() {
   var docs = document.getElementById("anchorExample").rel;
   document.getElementById("show").innerHTML = docs;
}

We have then created a button named "Click Me" to execute the display function ?

Updated on: 2026-03-11T22:50:45+05:30

194 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements