HTML a tag is also known as anchor tag. It defines a hyperlink
that links one page to another. The href
HTML attribute is used to give the reference(Path) of the page or document to be linked.
The <a>
tag is a paired tag with </a>
tag as a closing tag. Whatever is written between these two tags will feature as a hyperlink on the webpage.
The href attribute in HTML is used in a tag to give the reference(location URL) of other webpage. The full form of href is Hypertext REFerence. In simple words you just have to paste the url of the webpage in href, that you want to link.
Example: <a href=”https://www.codelivly.com”>Visit our Website Codelivly</a>
In the example below, the text “Visit our HTML tutorial” will work as a hyperlink and will take the user to our html tutorial page. We have given the address(Path) of that page as a reference in thehref
attribute.
<html lang=”en”>
<head>
<meta charset=”UTF-8″>
<title> HTML Anchor Tag </title>
</head>
<body>
<a href=”https://www.codelivly.com/python-tutorial/”> Learn Python Programming</a>
</body>
</html>
Output
HTML Target Attribute
HTML target
attribute is used to specify the place in the browser where the linked document should be opened. For example, whether the user wants to open the link in a new tab, new window, or in the same tag. The target attribute has different values for all these different locations.
The target
attribute can have one of the following values:
Value | Description |
---|---|
target=”_blank” | Opens the linked document in a new window or tab. |
target=”_self” | Opens the linked document in the same window/tab. This is the default value. |
target=”_parent” | Opens the linked document in the parent frame. |
target=”_top” | Opens the linked document in the full body of the window. |
target=”_framename” | Opens the linked document in a named frame. |
Note: HTML Frames are deprecated in HTML 5 and it is recommended not to use them.
<html lang=”en”>
<head>
<meta charset=”UTF-8″>
<title> HTML Anchor Tag Example </title>
</head>
<body>
<p><a href=”https://www.codelivly.com/” target=”_blank”>Codelivly – A Way For Coders</a></p>
<p><a href=”https://www.codelivly.com” target=”_top”>Codelivly – A Way For Coders</a></p>
<p><a href=”https://www.codelivly.com” target=”_parent”>Codelivly – A Way For Coders</a></p>
<p><a href=”https://www.codelivly.com” target=”_top”>Codelivly – A Way For Coders</a></p>
</body>
</html>