Menu Close
HTML Tutorial

HTML Links

The links help to go one page from another page or another source. The HTML links are represented in an <a> tag. Check the below example to know more.

Syntax

<a href="url">link text</a> 
  • The href attribute is used to specify the destination or address of the link.
  • Link text part will be visible to the reader

Example

<html>
<head>
    <title>HTML Links</title>
</head>
<body>
    <a href="https://www.codeamend.com/">Visit our HTML tutorial</a>
</body>
</html> 

Output:

HTML-Links

Image and Button Links:

The HTML links can be added as image, text and button. Follow the below example know these links.

Example

<html>
<head>
    <title>HTML Links</title>
</head>
<body>
    <h1>HTML text, image and button links</h1>
    <a href="https://www.codeamend.com/">Text link</a><br><br>
    <a href="https://www.codeamend.com/"><img src="c1.jpg"></a><br><br>
    <button onclick="document.location='https://www.codeamend.com/'">Button link</button>
</body>
</html> 

Note: Here, we can’t add link directly to the button. We need some script to add link in to the button.

HTML links - Target Attribute:

The html links have some target attribute values. The target attribute specifies where to open the linked document.

Target Attribute Values

Target Value

Description

_blank

Opens the linked document in new tab

_self

Opens in linked document in the same tab/window

_parent

Opens the linked document in the parent frame

_top

Opens the linked document in the full body of the window

Example

<html>
<head>
    <title>Target Attribute Values</title>
</head>
<body>
    <h2>Target Attribute Values Example</h2>
    <a href="https://www.codeamend.com" target="_blank">Visit our HTML tutorial</a><br><br>
    <a href="https://www.codeamend.com" target="_self">Visit our HTML tutorial</a><br><br>
    <a href="https://www.codeamend.com" target="_top">Visit our HTML tutorial</a>
</body>
</html> 
Popular HTML Blogs