HTML Links

Links can be found on almost every web page. Users can navigate from page to page by clicking on links.
 

HTML Links - Hyperlinks

Hyperlinks are HTML links. You can jump to another paper by clicking on a link. The mouse arrow will turn into a small hand when you move the mouse over a link.

 

HTML Links – Syntax

The HTML tag defines a hyperlink. It has the following syntax:

<a href="your url">Some text</a>

 

  • The href attribute, which indicates the link's destination, is the most significant attribute of the element.
  • The part of the link text that will be visible to the reader is the link text.
  • The reader will be directed to the provided URL address by clicking on the link text.

 

Example :

This example shows how to create a link to readytocode.net:

<!DOCTYPE html>
<html>
<body>

<h1>HTML Links</h1>

<p><a href="https://readytocode.net//">Visit Our Blog</a></p>

</body>
</html>

Try with example

 

In all browsers, links will show as follows by default:

  • A link that has not been visited is highlighted in blue.
  • A clicked link is highlighted in purple.
  • A link that is active is highlighted in red.

 

HTML Links - The target Attribute

The linked page will open in the current browser window by default. To modify this, you'll need to adjust the link's target. The target attribute defines where the linked page should be opened.

One of the following values can be assigned to the target attribute:

  • _self - The default value. The document is opened in the same window/tab as when it was clicked.
  • _blank - Displays the document in a new tab or window.
  • _parent - This command displays the document in the parent frame.
  • _top - Displays the document in the window's whole body.

 

Example :

To open the referenced document in a new browser window or tab, use target="_blank":

<!DOCTYPE html>
<html>
<body>

<h1>HTML Links</h1>

<p><a target="_BLANK" href="https://readytocode.net//">Visit Our Blog</a></p>

</body>
</html>

Try with example