HTML text link

In this tutorial, we will learn about HTML text links. Whenever we hover the mouse over the HTML link, it redirects to another page, image, or website. We will explore how they work and how to create them.

1. href attribute

It stands for hypertext reference. The first requirement in the creation of a hyperlink is a document address.

for example:

 <a href="https://www.facebook.com">Facebook</a>

In this, https://www.facebook.com is the value we are assigning to the href attribute. So whenever we click on Facebook, it will redirect us to the Facebook home page link. We can also put our own HTML link to href.

for example:

<a href="demo.html">My own page</a>

2. target attribute

The target attribute is used to specify where to open the linked document.  The target attributes has many parts:

  • _parent: It opens the page in the same iframe if there is no parent or in parent iframe.
  • _blank: It opens the page into the new tab.
  • _top:  It opens the attached document in the full window.
  • _self:  It opens the page in the same window when it is clicked. This is the default.

we can modify it:

<a href="http://www.demo.com" target="_blank" rel="noopener">Our Link text</a>

Here target=”_blank” is the syntax for using it.

3. name attribute

The name attribute supports button, select, form, frame,  input, object, map and meta elements. It is used to navigate to specific point on the page.

<a name="to start"></a> or

In this, without scrolling down, simply click to go to the start of the page.

<a href="#SomeSection">Section Abc</a>

This will identify the section.

<a href="otherpage.html#title">Link your text in this</a>

We can move to the “title” of some another page.

Leave a Reply

Your email address will not be published.