Anchor Tag or Hyperlink

Anchor Tag or HTML Anchor Tag <a> defines a Hyperlink <a href=""> in html document. A hyperlink links a webpage with other webpages and external pages. A hyperlink can be Internal Link, External Link, Internal Link, Mail Link or telephone link .

In HTML5, an anchor tag can contain both block level and inline level elements. That means, we can write text, image or a div inside anchor tag. Also anchor tag with href is known as hyperlink.


Anchor Tag

Anchor Tag is a tag used to build hyperlinks.


<a>Anchor Tag</a>
                    

Hyperlink means an Anchor Tag with href attribute. Hyperlink is used to link webpages.


<a href="">Hyperlink Tag</a>
                    

Type of Hyperlinks

There are six types hyperlinks. Types of Hyperlinks are defined on the basis of their value. Here are six type of html hyperlinks with example and usage.

Hyperlinks Types

  1. Empty Link
  2. Relative Link
  3. Absolute Link
  4. Internal Link
  5. Mailto Link
  6. Telephone Link







Hypertext Reference ( href="")

href attribute is used in an anchor tag to specify the URL( Uniform Resource Location) of the page link to go. It can be a relative link, absolute link or an id.


A relative Link is used to link pages within same domain.

Example of Relative link


<a href="contact.html">Link 1</a>   	
Relative link in same directory

<a href="blog/blog1.html">Link 2</a>   	
Relative link in child directory

<a href="../cart.html">Link 3</a>   	
Relative link in parent directory

An Absolute Link is used to link pages from their Absolute Path. for exp
<a href="http://www.domain.com">Link</a> is an Absolute Link as it contains domain name and page.

Example of Absolute link?


<a href="http://www.domain.com">Link</a>                                    
( Absolute Link) 

<a href="https://www.facebook.com/thetechaltum">Join us on Facebook</a>     
 ( Absolute Link of facebook page)



Target attribute

A target attribute ( target="" ) is used to tell window where to open that particular link.
Various values of target

  1. _self ( By Default) Open the link in same window
  2. _blankopen link in new tab
  3. name of frame( iframe or frame)Open the link on frame whose name is there

Values of target attribute

		
<iframe name="frame1" ></iframe>

<a href="http://www.techaltum.com" target="_self">_self</a>
<a href="http://www.techaltum.com" target="_blank">_blank</a>
<a href="webdesigning.html" target="frame1">frame1</a><

Click on the link to see behavior of following target



_blank
frame1