HTML Links


HTML Links are also known as hyperlinks(anchor tag). the anchor element begins with the tag and ends with the tag. which is used to link from one web page to another web page.

The href attribute is the most important attribute of the hyperlinks. this attribute is used to add the destination path.

Syntax

<a href="url">here  link text</a>

Example

<!DOCTYPE html>
<html>
   <head>
      <title>Hyperlink Example</title>
   </head>
   <body>
      <p>Click following link</p>
      <a href="https://webprogrammingtutorials.com/">Web Programming Tutorials</a>
   </body>
</html>

The target Attribute

There are five types of value a target attribute. so you can see the below list.

Value Description
_blank Opens the linked document in a new window or tab
_self Opens the linked document in the same window
_parent Opens the linked document in the parent window
_top Opens the linked document in the full body of the window
targetframe Opens the linked document in a named target frame

Example

<!DOCTYPE html>
<html>
   <head>
      <title>Hyperlink Example</title>
   </head>	
   <body>
      <a href="https://w3snippets.com/html-tutorial/" target = "_blank">Opens in New</a> |
      <a href="https://w3snippets.com/html-tutorial/" target = "_self">Opens in Self</a> |
      <a href="https://w3snippets.com/html-tutorial/" target = "_parent">Opens in Parent</a> |
      <a href="https://w3snippets.com/html-tutorial/" target = "_top">Opens in Body</a>
   </body>

</html>