HTML LINKS


HTML links are also called hyperlink.

HTML links are connected from one webpage or web resource to another. By clicking a hyperlink you jump to another webpage or web resource.

We generally use hypertext (Hypertext is a text within hyperlink) to be clicked upon to go to a new web page.

Note: It is not necessary that a link can only have text. It may be an image, Button or other HTML element too.


HTML link Syntax:

We use <a> tag to define hyperlink.<a> tag is known as Anchor tag:

<a href="https://www.tutorialstonight.com/">Click here</a>

Click <a href="https://www.tutorialstonight.com/">here</a> to go to Homepage
Try It

Syntax explanation:


Apart from href attribute there are other attributes too.
Like:

Let's discuss these attributes.


HTML Link - Target Attribute

target attribute is used to specify where the linked document should be opened. Whether it will open in the same tab or on a different tab.

This attribute has following values:

Here is an example and you can change different values to see the difference in the practice section.

Click <a href="https://www.tutorialstonight.com/" target="_blank">here</a> to go to Homepage
Try It

HTML Link - title attribute

title attribute provides additional information about HTML link.When user takes its cursor over the link then value provided for title attribute is shown in a box.

Click <a href="https://www.tutorialstonight.com/" title="Go to Homepage">here</a> to go to Homepage
Try It

Image as Hyperlink

As mentioned above we can use image also as HTML link.Here is an example:

This image is <a href="https://www.tutorialstonight.com/"><img src="flower.jpg"></a> to go to Homepage
Try It

HTML Link - Bookmark

You can also use HTML links to create bookmarks on the same web page. Clicking on the link will instantly take you to that part of the web page.

Here is an example that will take you to HTML link syntax.

click here to jump to HTML link syntax.

Here is how to create a web page bookmark.

  1. First create an id to the part of the web page where you want to jump.

  2. <h4 id="bookmark1">HTML Link syntax</h4>
  3. Now in <a> tag provide href value="#id_name"

  4. <a href="#bookmark1">Go to HTML Link syntax</a>