The HTML Anchor Tag is written as <a>.
The most common use of the HTML Anchor Tag is to provide a Hyperlink to another webpage and in order to do so we need to use the href attribute of the HTML Anchor Tag.
By default the hyperlinks will appear as follows in all the browsers.
- Unvisited Link: Underlined and blue in color
- Visited Link: Underlined and purple in color
- Active Link: Underlined and red in color
The HTML Anchor Tag won’t be able to do anything on its own; it needs attributes and value to function properly.
Attributes available for the HTML Anchor Tag are:
Value of Attribute
Description of Attribute
|Defines the character set of the linked document (Not supported in HTML 5)
|Defines the co-ordinates of the link (Not supported in HTML 5)
|Specifies the URL of the resource or webpage the links points to.
|Defines the language of the linked document.
|Specifies for what media/device the link is optimized.
|Defines the name of the anchor (Not supported in HTML 5)
|Defines the relationship between the current resource/ webpage and the linked resource/webpage.
|Defines the relationship between the linked resource/ webpage and the current resource/webpage. (Not supported in HTML 5)
|Defines the shape of the link (Not supported in HTML 5)
|Defines where to open the linked resource/webpage
|Defines the MIME type of the linked resource/webpage
Example of HTML Anchor Tag
HTML anchor tag Code
<a href="http://techhoney.com/" target="_blank">Link for Techhoney </a>
|Link for Techhoney
Here in the above HTML Anchor Tag example we can see that the href attribute has value of “http:/www.techhoney.com” and the target attribute has value of “_blank” which means that once we click on the above hyperlink we will open the home page of www.techhoney.com in a new browser window/tab.
Here the target attribute’s value allows us to open the linked resource/webpage in new browser window/tab.
HTML Anchor Tag Supporting Browsers
Important points about HTML anchor tag:
hreflang, media, rel, target, and type attributes cannot be present in the HTML anchor tag if the href attribute is not present.
by default any hyperlink will open in the same browser window until and unless specified with the target attribute.