Anchor tag in HTML

HTML Anchor
To define a hyperlink to other web pages, files, location, or any URL, using the “href” attribute, the HTML anchor tag is used. The “href” attribute specifies the address of the destination page.

Appearance:
Unvisited link: Underlined and Blue.
Visited link: Underlined and purple.
Active link: Underlined and red.

Syntax:

<a href = "..........."> Content </a>

Example:

<!DOCTYPE html>
<html>
<head>
<title>Example</title>
</head>
<body>
<h3>Contact Us</h3>
<address>Email ID: <a href="#"> 1234@exampledomain.com</a></address>  
</body>
</html>

Output:




Example


Contact Us

Email ID: [email protected]

Explanation: 

In the above example, the <address> tag is used to specify the contact information which is thus displayed in italic font. Here, the anchor tag is used to define a hyperlink for a mail id using the “href” attribute.

 

HTML Anchor with the target attribute: 

To open a link to another page, the target attribute of the HTML anchor tag is used. If the target attribute is not used, then the added link opens on the same page

Example:

<!DOCTYPE html>
<html>
<head>
<title>Example</title>
</head>
<body>
<h3>Contact Us</h3>
<address>Email ID: <a href="#" target="_blank"> 1234@exampledomain.com</a></address>  
</body>
</html>

Output:




Example


Contact Us

Email ID: [email protected]

Explanation: 

In the above example, the <address> tag is used to specify the contact information which is thus displayed in italic font. Here, the anchor tag is used to define a hyperlink for a mail id using the “href” attribute. Here, the “target” attribute is used to open the mentioned link to another page and not on the same page.

 

Please Share