Open In App

HTML DOM Anchor rel Property

Last Updated : 02 Jan, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

The Anchor rel Property in HTML DOM is used to set or return the value of the rel attribute of a link. The rel attribute is used to specify the relation between the current document and the linked document.

Syntax:

  • It returns the Anchor rel property. 
anchorObject.rel
  • It is used to set the Anchor rel property. 
anchorObject.rel = "value"

Property Values:

Value

Description

alternate

It defines an alternate version of the document i.e. print page, translated or mirror.

author

It defines the author of the document.

bookmark

It specify a related document.

help

It specifies a help document.

license

It defines a copyright information for the document.

next

It defines the next document in a selection.

nofollow

It is used by Google, to specify that the Google search spider should not follow that link and mostly used for paid links.

noreferrer

It is used to Specify that the browser should not send a HTTP referrer header if the user follows the hyperlink.

prefetch

It specifies that the target document should be cached.

prev

It specify the previous document in a selection.

search

It specify the search tool for the document.

tag

It specifies a tag keyword for the current document.

Return Value: It returns a string value which represents the relation between the current document and the linked document.

Example 1: This example returns the Anchor rel Property. 

html




<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML DOM Anchor rel Property
    </title>
</head>
 
<body style="text-align: center;">
    <h1>GeeksforGeeks</h1>
 
    <h2>DOM Anchor rel Property</h2>
 
    <p>Welcome to
        <a href="https://www.geeksforgeeks.org"
            id="GFG" rel="nofollow"
            target="_self">
            GeeksforGeeks
        </a>
    </p>
 
    <button onclick="myGeeks()">
        Submit
    </button>
 
    <p id="sudo"></p>
 
    <!-- Script to return Anchor rel Property -->
    <script>
        function myGeeks() {
            let x = document.getElementById("GFG").rel;
            document.getElementById("sudo").innerHTML = x;
        }
    </script>
</body>
 
</html>


Output: 

anchor-rel

Example 2: This example sets the Anchor rel Property. 

html




<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML DOM Anchor rel Property
    </title>
</head>
 
<body style="text-align: center;">
    <h1>GeeksforGeeks</h1>
 
    <h2>DOM Anchor rel Property</h2>
 
    <p>Welcome to
        <a href="https://www.geeksforgeeks.org"
            id="GFG" rel="nofollow"
            target="_self">
            GeeksforGeeks
        </a>
    </p>
 
    <button onclick="myGeeks()">
        Submit
    </button>
 
    <p id="sudo"></p>
 
    <!-- Script to set Anchor rel Property -->
    <script>
        function myGeeks() {
            let x = document.getElementById("GFG").rel
                = "noopener";
 
            document.getElementById("sudo").innerHTML
                = "The value of rel attribute "
                + "is changed to " + x;
        }
    </script>
</body>
 
</html>


Output:

anchor-rel-2

Supported Browsers:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari


Previous Article
Next Article

Similar Reads

HTML | DOM Link rel Property
The HTML | DOM Link rel Property in HTML DOM is used to set or return the value of the rel attribute of a linked document. The rel attribute is used to specify the relation between the current document and the linked document. Syntax: It returns the rel property.linkObject.relIt is used to set the rel property.linkObject.rel = relationship Property
3 min read
HTML | DOM Anchor password Property
The Anchor password Property in HTML DOM is used to set or return the password part of the href attribute value. The password part is entered by the user in the URL and it is specified after the username and the hostname. For example: https://manaschh:manaschhabra499@www.geeksforgeeks.org/ (manaschh is the username and manaschhabra499 is the passwo
2 min read
HTML | DOM Anchor username Property
The Anchor username Property in HTML DOM is used to set or return the value of the username part of the href attribute. The username part is used to define the username entered by the user. It is specified after the protocol and before the password part. For example: https://manaschhabra:manaschhabra499@www.geeksforgeeks.org/ (manaschhabra is the u
2 min read
HTML | DOM Anchor origin Property
The Anchor origin property in HTML DOM is used to return the protocol, hostname and port number of the href attribute value. It is the readonly property that returns a string value which represents the protocol, domain name and the port number of the URL. Syntax: anchorObject.origin Below program illustrates the use of Anchor origin Property in HTM
1 min read
HTML | DOM Anchor hostname Property
The DOM Anchor hostname Property in HTML DOM is used to set or return the hostname part of the href attribute value. Syntax: It returns the hostname property. anchorObject.hostname It is used to set the hostname property: anchorObject.hostname = hostname Property Values: It contains the value i.e hostname which specify the hostname of the URL. Retu
2 min read
HTML DOM Anchor rev Property
The HTML DOM Anchor rev property is used to set or return the value of the rev attribute of the &lt;a&gt; element. The rev attribute is used to specify the relationship between the linked document and the current document. Note: This property is not supported by HTML5. Syntax: It returns an anchor rev property. anchorObject.rev It is used to set th
2 min read
HTML DOM Anchor target Property
The Anchor target Property in HTML DOM is used to set or return the value of the target attribute of a link. The Target attribute is used to specify where to open the link. Syntax: It returns the target property. anchorObject.targetIt is used to set the target property. anchorObject.target = "_blank|_self|_parent|_top|framename" Property Values: Pr
2 min read
HTML DOM Anchor protocol Property
The Anchor protocol Property in HTML DOM is used to set or return the value of the protocol part of the href attribute value. The protocol is used to specify how data are transmitted between two computers.  Syntax:   It returns the Anchor protocol property. anchorObject.protocolIt is used to set the Anchor protocol property. anchorObject.protocol =
2 min read
HTML DOM Anchor type Property
The Anchor type Property in HTML DOM is used to set or return the value of the type attribute of a Link. The type attribute is used to specify the MIME type of the target URL and it is usually purely advisory. Syntax: It returns the Anchor type Property. anchorObject.type It is used to set the Anchor type Property. anchorObject.type = MIME-type Pro
2 min read
HTML DOM Anchor port Property
The Anchor port Property in HTML DOM is used to set or return the port part of the href attribute value. It has a default value 80 or 443. If the port number is not specified in the URL then some browsers will return 0 or undefined. Syntax: It returns the port property. anchorObject.portIt is used to set the port property. anchorObject.port = numbe
2 min read
Article Tags :