HTML Anchor Tag

The HTML Anchor Tag characterises a hyperlink that links one page to another page. It will create the hyperlinks to other web pages as well as files, location, or any URL. The "href" attribute is the main attribute of the HTML tag. 

it links to the destination page or URL.

href attribute

The href attribute is used to clarify the address of the file to be linked. In other words, it identifies the destination page.

The syntax of HTML anchor tag is define below.

<a href="web URL Or File URL  or Any Location URL">Link Text</a>

 

Let's see some example of HTML anchor tag which is given below.

<a href="sample.html" >Click for Sample Page</a>
  Try it Yourself

Set out a location for Link using target attribute

If we want to open a link to another page or any file url then we can use the target attribute of <a> tag.

The target attribute defines where to open the linked document.

_self - It will open the document in the same window/tab as it was clicked as default behaviour.

_blank - it will open the document in the new window or tab.

_parent - it will open the document in the parent frame.

_top - it will open the document in the full body of the window.

Example :

<a href="sample.html" target="_blank" >Open Link in New Window or Tab</a><br><br>
<a href="sample.html" target="_self"  >Open Link in SameWindow or Tab</a><br><br>
<a href="sample.html" target="_parent"  >Open Link in Parent Frame</a><br><br>
<a href="sample.html" target="_top"  >Open Link in Full Body of Window</a>
  Try it Yourself

Appearance of HTML anchor tag

An unvisited link is displayed underlined and blue.

visited link displayed underlined and purple.

An active link is underlined and red.

Tip : Links can of course be styled with CSS, to get another look!

Element Chrome Browser Chrome ie browser IE firefox Firefox opera Opera safari Safari
<a> Yes Yes Yes Yes Yes