HTML Links

Mohammed Imtiyaz Nov 29, 2014

A hyperlink is a group of words that can be clicked to navigate to another page.

When you place the cursor over the link in the webpage, the arrow will turn into litle hand.

The most important attribute of hyperlink is href attribute, which indicates the link's destination.


<a href="URL">Your Text</a>

URL: Uniform Resource Locator
a: Anchor
href: Hypertext Reference


<a href="">Visit</a>
Tip: By default, links will appear as follows in all browsers.
  • An unvisited link is underlined and is blue in color.
  • A visited link is underlined and is purple in color.
  • An active link is underlined and is red in color.

Html Target Attribute

The target attribute specifies where to open the linked document.


<a href="url" target="_blank">Text</a>


<a href="" target="_blank">Visit</a>

Target attributes and their descriptions

Attributes Description
_blank Opens the linked document in a new window or tab
_self Opens the linked document in the same window as it was clicked
_parent Opens the linked document in the parent window
_top Opens the linked document in the full body of the window


Link to an element with a specified id within a page:

<a href="#top">Go to top</a>
Note: The name attribute is not supported in HTML5


Link to an email address with a specified subject

<a href="">Send email mail!</a>
Note: will only work if you have mail installed


Link to a JavaScript

<a href="javascript:alert('Hello World!');">Execute JavaScript</a>