HTML Link Tag

Html Link Tag

HTML link tag or hyperlink is a relation between one web page to another web page. Links are very useful during navigating from one page to the other web page.

Followings are the properties of the link.

  • An unvisited link is underlined and blue.
  • A visited link is underlined and purple.
  • An active link is underlined and red.

HTML Link Syntax

Links are created in HTML using <a> tag.Anything between opening <a> tag and closing </a> tag is a link and it is visible to the screen.

General Syntax Of Creating HTML Links

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

HTML link or hyperlink is a relation between one web page to another web page. Links are very useful during navigating from one page to another web page.

Creating HTML Link

Source Code

Try it now

Note: Here, URL denotes either absolute URL or relative URL. Absolute URL is the full path of the web page while is relative URL is the relative path of the web page. Please note that https://www.google.com and https://www.sudhakarinfotech.com is an absolute URL while about.php,contact.php is the relative path.

Target Attribute Of HTML Links

Target attributes the value of the HTML links decide where to open the linked document. There are four values of target attribute and every value of targets attribute starts with an underscore(_) character.

_blank - Opens the HTML linked document in a new window or tab & changes the color of the linked element.

<a href="display.php" target="_blank">Result</a>

Source Code

Try it now

Note Link attribute _blank - Opens the Html linked document in a new window.

_parent - Opens the Html linked document in the parent window & changeS the color of the linked element.

<a href="display.php" target="_parent">Result</a>

Source Code

Try it now

Note: Link attribute _parent opens the Html linked document in the parent window.

_self - Opens the HTML linked document in the same window & change the color of the linked element

<a href="display.php" target="_self">Result</a>

Source Code

Try it now

Note: Link attribute _self opens the Html linked document in the same window.

_top- Opens the Html linked document in the full browser window & changeS the color of the linked element

<a href="display.php" target="_top">Result</a>

Source Code

Try it now

Note: Link attribute _top opens the Html linked document in the full browser window.

How To Create HTML Link -Image/Title/Download

Image Link- To link an image,just put HTML element <img> tag within <a> tag.

<a href="result.php" target="_blank"><img src="result.png" alt="test result"></a>

Source Code

Try it now

Note: Place the image inside the link element & provide path detail to href attribute of the link element.

Title Link-Just put any HTML heading tag within <a> tag.

<a href="sudhakarinfotech.com" target="_blank"><h5>sudhakarinfotech</h5></a>

Source Code

Try it now

Note: Place header element inside <a> element & provide path detail to href attribute of the link element.

Download Link

A download link can be created, just pointing the download link to href of anchor tag.Here is the example of creating download link of zip,pdf and png files.

<a href="downloads/result.pdf">Download PDF file</a><br> <a href="downloads/question.zip">Download Zip file</a><br> <a href="downloads/image.jpg">Download Image file</a><br>

Source Code

Try it now

Note: Place link text inside <a> element & provide path detail to href attribute of the link element.

Online Test / Quiz