HTML Link Tag

HTML Link Tag (Hyperlink) as the name implies is a feature which redirects to the specified web address(URL) when clicked.

Both text and images can be used as links.

Links can be created using <a> tag.

The 'href' attribute of <a> tag defines the destination URL of the link.

In all web browsers by default, links are underlined and their HTML link color changes based on their state (unvisited, visited, active).

  • Unvisited - Blue color
  • Visited - Purple color
  • Active - Red color

HTML Links Example

Example



<a href="www.ieatcss.com">Web Design Tutorial</a> 

		

Preview


Target Attribute

Target attribute is very important in links, it decides how the action of link is performed. Whether to open the link in a new window, same window, same frame or parent frame.

Attribute Value and Description
Value Description
target="_blank" HTML link new window
target="_self" Opens the link in the same frame
target="_parent" Opens the link in the parent frame
target="_top" Opens the link in the full body of the window
target="framename" Opens the link in the specified frame

Don't worry if its hard to understand frame. You will more about the frames later.

Example



<a href="www.ieatcss.com" target="_blank">Web Design Tutorial</a> 
<a href="www.ieatcss.com" target="_self">Web Design Tutorial</a> 
<a href="www.ieatcss.com" target="_parent">Web Design Tutorial</a> 
<a href="www.ieatcss.com" target="_top">Web Design Tutorial</a> 



		

Preview

Id Attribute

Id attribute can be used to send the visitors to specified section of the same page using links. For instance, in wikipedia if you click on the index terms, it will send to the specified section on the same page.

Id attribute can also be used to send the visitor to the specified section of a different page. The below sample code shows both.

Example



<a href="#demo">Same Page</a> 
<a href="www.ieatcss.com#demo">Different Page</a> 

		

Preview

Next Lesson > HTML Lists