HTML Anchor
To define a hyperlink to other web pages, files, locations, 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="#"> [email protected]</a></address> </body> </html>
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" rel="noopener"> [email protected]</a></address> </body> </html>
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.