What is Hyperlink?

A hyperlink is usually a link that links one web page to another. Through a hyperlink, it helps you to link the pages of your website to other web pages or pages of other websites.


How To Create a Hyperlink in HTML ?

Hyperlink in HTML

HTML uses an anchor element for hyperlink. This anchor element consists of <a > and </a> tags. Clicking on the text written between these two tags takes us to another web page.

We can understand this by the example given below:

<a href="codexradar.com">CodexRadar</a> code-box

In the example above, when we click on the text CodexRadar, it takes us to the homepage of CodexRadar.


HTML Hyperlink Target Attribute

When the user clicks on a link, whether to open the link in the same page or open it in the new page. This is controlled by the hyperlink's target attribute.

We can use four types of targets, which are as follows:

1.  _self : This is the default target of hyperlink which opens the web page in the same web page.

<a href="codexradar.com" target="_self">CodexRadar</a> code-box

2.  _parent : This opens the link in the parent window.

<a href="codexradar.com" target="_parent">CodexRadar</a> code-box

3.  _top : This opens the link in the full browser window.

<a href="codexradar.com" target="_top">CodexRadar</a> code-box

4.  _blank : This opens the link in the new window/tab.

<a href="codexradar.com" target="_top">CodexRadar</a> code-box


HTML Hyperlink Types

There are three types of HTML hyperlink which appear in different colors in the browser. Which is as follows:

1. Active Links : These links appear in red.

2. Visited Links : These links appear in purple.

3. Unvisited Links : These links appear in blue.


HTML Hyperlink : Bookmarks

We use bookmarks when the content is too much in the HTML document and we have to send the user to a particular part of the content.

While bookmarking, we must first set the id attribute of the element where we want to send the user. Now we create a hyperlink using this id. Then whenever we click on that hyperlink, it will take us directly to the element whose id we have set.

You can see an example of this below:

<h1 id="heading1">Heading 1</h1>
<p>Some Example Text. Some Example Text. Some Example Text. Some Example Text. Some Example Text. Some Example Text. Some Example Text. Some Example Text. Some Example Text. Some Example Text.</p>
<a href="#heading1" target="_top">Go To Heading 1</a> code-box


HTML Hyperlink : Email Address

We can also link email through hyperlink. Then whenever we click on the email, a window will automatically open for sending the email.

For this, we have to write mailto: then email address. You can see this in the example below:

<a href="mailto:codexradar@gmail.com" target="_top">Send an Email to CodexRadarr</a> code-box

Summary

In this post we learn how to create a hyperlink in HTML. You try to make it yourself. I hope you make. If you face any problem, then comment and tell us. Keep visiting the blog to read more similar posts.

Post a Comment

Previous Post Next Post