× Introduction HTML Editors Web Components Headings Paragraph Attributes Entities Images Comments Formatting Links File Paths Book Marks Image Links Unordered Lists Ordered Lists Tables Forms Other Form Elements Semantic tags Media Div and Span Examples Projects eBooks









HTML Links - Hyperlinks

In this tutorial you will learn how to create links to other pages in HTML.

A link or hyperlink is a connection from one web resource to another. Links allow users to move seamlessly from one page to another, on any server anywhere in the world. Links are specified in HTML using the <a> tag. The href attribute of this tag identifies the page to be loaded.

<a href="url">Link text</a>

The element content (Link text) defines the part to be displayed. The element content doesn’t have to be text. You can link from an image or any other HTML element.

Example:   Try It

<a href= "aboutus.php">About us </a>
<a href= "https://www.google.com/">Google </a>


By default, the content of a link is underlined. If it hasn’t been visited, it is blue. If it has been visited, it is purple. If it active, it is red. But there is no default for hovering.


Setting the Targets for Links

Setting The target attribute tells the browser where to open the linked document. There are four defined targets, and each target name starts with an underscore(_) character:

  • _blank — Opens the linked document in a new window or tab.
  • _parent — Opens the linked document in the parent window.
  • _self — Opens the linked document in the same window or tab as the source document. This is the default, hence it is not necessary to explicitly specify this value.
  • _top — Opens the linked document in the full browser window.

Example:   Try It

<a href= "aboutus.php" target="_blank">About us </a>
<a href= "https://www.google.com/" target="_blank">Google</a>      

Internal Links

An internal link is a type of hyperlink whose target or destination is on the same website or domain.

Example:   Try It

<a href= "home.php" target="_blank">Home</a>
<a href= "courses.php" target="_blank">Courses</a>
<a href= "aboutus.php" target="_blank">About us </a>
<a href= "contactus.php" target="_blank">Contact us </a>   
      

External Links

An external link is a type of hyperlink whose target or destination is on another website or domain.

Example:   Try It

<a href= "home.php" target="_blank">Home</a>
<a href= "courses.php" target="_blank">Courses</a>
<a href= "aboutus.php" target="_blank">About us </a>
<a href= "contactus.php" target="_blank">Contact us </a>   
w3schools
Tutorial Point
FlipKart
Amazon      

Practice exercise:

1.Write an html code to display the web page as follows. View


Sri Hari Book Store


Home Courses About us Contact us

Mission

"sriharibookstore.com is committed to bringing the most convenient, easy and secure shopping experience on the web."

Products

10 Million Books across 20+ Languages, Audio Books, Gadgets & Accessories, Toys, Electronics, Mobiles & Tablets Accessories, Health Care Devices and Many More Stores.

Highlights

sriharibookstore.com has been awarded the most promising Start-Up company 2013.
The Most Prompt Customer Service & Support 2013-2014.
India's largest Book Warehouse - India Book of Records 2013 -2014.