HTML anchor tag is used to put hyperlinks inside HTML. This anchor tags are used to link pages and move from one page to another page.
Syntax
1 |
<a href="put target url here...">Enter link text content...</a> |
Example
1 |
<a href="https://tutorialdeep.com/html_tutorial/html-paragraph/">Visit HTML paragraph tutorial page</a> |
Output
Anchor tag with absolute web url
An absolute web address is an address inside href attribute of anchor tag given by full website url.
1 |
<a href="https://tutorialdeep.com/html_tutorial/html-paragraph/">HTML paragraph tutorial</a> |
Output
Anchor tag with relative web url
A relative web address is a address point to the same website.
1 |
<a href="../html-anchor/">HTML anchor</a> |
Output
Anchor tag target attribute
The target attribute of anchor tag is used to specify the location to open the linked web document.
Sr. No. | target atribute options | Description |
---|---|---|
1 | _blank | Open the linked document in the new window/tab |
2 | _self | Open the linked document in the same window/tab |
3 | _parent | Used to create header cells in a table. |
4 | _top | Used to create a cells in each rows of a table. |
1 2 3 4 |
<a href="../html-anchor/" target="_blank" rel="noopener noreferrer">HTML anchor tutorial</a><br> <a href="../html-anchor/" target="_self" rel="noopener noreferrer">HTML anchor tutorial</a><br> <a href="../html-anchor/" target="_parent" rel="noopener noreferrer">HTML anchor tutorial</a><br> <a href="../html-anchor/" target="_top" rel="noopener noreferrer">HTML anchor tutorial</a> |
Output
HTML anchor tutorial
HTML anchor tutorial
HTML anchor tutorial
Anchor tag with email links
If you want your users to mail you some message then you have to place your email id with subject inside href attribute of anchor tag.
Output
Anchor tag with download links
If you want place download link for files with extensions zip, doc, pdf etc. You need to place destination url of the file inside href attribute of the anchor tag
1 2 3 |
<a href="file.zip">file for zip</a> <a href="file.doc">file for doc</a> <a href="file.pdf">file for pdf</a> |
Output
file for doc
file for pdf