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.
We Will be looking at:
Attributes available for the HTML Anchor Tag are:
Value of Attribute
Description of Attribute
|charset||char_encoding||Defines the character set of the linked document (Not supported in HTML 5)|
|cords||coordinates||Defines the co-ordinates of the link (Not supported in HTML 5)|
|href||URL||Specifies the URL of the resource or webpage the links points to.|
|hreflang||language_code||Defines the language of the linked document.|
|media||media_query||Specifies for what media/device the link is optimized.|
|name||section_name||Defines the name of the anchor (Not supported in HTML 5)|
|Defines the relationship between the current resource/ webpage and the linked resource/webpage.|
|rev||text||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|
|type||MIME_type||Defines the MIME type of the linked resource/webpage|
Example of HTML Anchor Tag
HTML anchor tag Code
<a href="http://www.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.