

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML DOM Anchor rel Property
<p style="">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.</p><h2 style="">Syntax</h2><p>Following is the syntax to −</p><ul class="list"><li><p>a) Return the rel property −</p></li></ul><pre class="result notranslate">anchorObject.rel</pre><ul class="list"><li><p>b) Set the rel property &minus</p></li></ul><pre class="result notranslate">anchorObject.rel = "value"</pre><h2>Example</h2><p>Let us see an example of the HTML DOM anchor rel property −</p><p><a class="demo" href="http://tpcg.io/LdIbIsHd" rel="nofollow" target="_blank">Live Demo</a></p><pre class="prettyprint" style=""><!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></pre><h2 style="">Output</h2><p>This will produce the following output −</p><p style=""><img src="https://www.tutorialspoint.com/assets/questions/media/26302/anchor_rel.jpg" class="fr-fic fr-dib" style="width:500px; height:249px; border:1px solid black;" width="500" height="249"></p><p>Click on the “Click me!” button to get the HTML DOM Anchor rel property −</p><p style=""><img src="https://www.tutorialspoint.com/assets/questions/media/26302/anchor_rel_property.jpg" class="fr-fic fr-dib" style="width:500px; height:280px; border:1px solid black;" width="500" height="280"></p><p>In the above example −</p><p style="">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><pre class="result notranslate"><p> <a id="anchorExample" rel="Rel Property" href="https://www.examplesite.com/">Anchor Rel Property</a> </p></pre><p>We have then created a button named “Click Me” to execute the display function −</p><pre class="result notranslate"><button onclick="display()">Click me!</button></pre><p>The display function gets the rel property of the element with id=” Anchor example” −</p><pre class="result notranslate" style="">function display() { var docs = document.getElementById("anchorExample").rel; document.getElementById("show").innerHTML = docs; }</pre><p>We have then created a button named “Click Me” to execute the display function −</p>
- Related Questions & Answers
- HTML DOM Link rel Property
- HTML DOM Anchor search Property
- HTML DOM Anchor target Property
- HTML DOM Anchor text Property
- HTML DOM Anchor type Property
- HTML DOM Anchor username 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
Advertisements