
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
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 −
<!DOCTYPE html> <html> <body> <h1>Example</h1> <p><a id="anchorExample" rel="Rel Property" href="https://www.examplesite.com/"> Anchor Rel Property</a></p> <p>Click on the button</p> <button onclick="display()">Click me!</button> <p id="show"></p> <script> function display() { var docs = document.getElementById("anchorExample").rel; document.getElementById("show").innerHTML = docs; } </script> </body> </html>
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/
<p> <a id="anchorExample" rel="Rel Property" href="https://www.examplesite.com/">Anchor Rel Property</a> </p>
We have then created a button named “Click Me” to execute the display function −
<button onclick="display()">Click me!</button>
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 −
- Related Articles
- HTML DOM Link rel Property
- HTML DOM Anchor hostname Property
- HTML DOM Anchor protocol Property
- HTML DOM Anchor password Property
- HTML DOM Anchor pathname Property
- HTML DOM Anchor href Property
- HTML DOM Anchor origin Property
- HTML DOM Anchor port Property
- HTML DOM Anchor hreflang Property
- HTML DOM Anchor download Property
- HTML DOM Anchor hash Property
- HTML DOM Anchor search Property
- HTML DOM Anchor target Property
- HTML DOM Anchor text Property
- HTML DOM Anchor type Property
