Anchor Tag in HTML
The anchor tag, <a>, is one of the fundamental elements in HTML used for creating hyperlinks. It allows you to link to other web pages, resources, or even different sections within the same page. The anchor tag’s primary purpose is to establish connections between web pages and enable users to navigate seamlessly throughout a website.
In the below PDF we discuss about HTML Iframes in detail in simple language, Hope this will help in better understanding.
Here’s the basic syntax of an anchor tag:
<a href="URL">Link Text</a>
This attribute specifies the destination URL, where the user will be redirected when they click the link. The URL can be an absolute web address (e.g., https://www.topperworld.in) or a relative path to a file within the same website (e.g., page.html).
This is the text that users see and click on to access the linked page or resource. It’s enclosed between the opening and closing <a> tags.
Creating External Links:
External links are essential for connecting your web page to other websites or online resources. To create an external link, simply specify the URL in the href attribute of the anchor tag. Here’s an example:
<a href="https://www.topperworld.in">Visit Example.com</a>
Creating Internal Links
Internal links are used for navigating within your own website. To create an internal link, you can use relative URLs. These URLs point to resources within the same website. For example, to link to a page named “about.html” in the same directory, you can use:
<a href="about.html">About Us</a>
Linking to Email Addresses
You can also use the anchor tag to create links to email addresses. When a user clicks on the link, their default email client will open with a new message addressed to the specified email. Here’s how to create an email link:
<a href="mailto:firstname.lastname@example.org">Contact Us</a>
Anchor Tag Attributes:
There are five commonly-used Anchor Tag attributes:
The href attribute stands for hypertext reference. This attribute specifies the target URL (Uniform Resource Locator or address) you want your web document to connect to. The text enclosed between the opening and the closing anchor tags is a hyperlink/ hypertext and is authentically called Anchor Text. The cursor changes to that of a hand when you hover over it.
This tag enables users to jump to specific sections of a web document. This tag is especially useful for navigating across large pages. An important example of this could be:
This attribute regulates the execution of the target document. “target= ” _blank “is used for the opening of the target page in a new tab.
The title attribute shall give you an indication of the final, targeted destination. If you hover over the link with your mouse, you can see the title displayed.
The ping attribute is used to specify space-separated URLs to send POST requests to these URLs each time the link is clicked.
An anchor tag, also known as the <a> tag, is an HTML element used to create hyperlinks on a web page. It allows you to link to other web pages, resources, or specific sections within the same page.
To create a basic hyperlink, you use the <a> tag with the href attribute.
The title attribute is used to provide additional information about the linked resource. When a user hovers their cursor over the link, the text in the title attribute is displayed as a tooltip.
To create a mailto link, you use the href attribute with the “mailto:” protocol followed by the email address you want to link to.
To open a hyperlink in a new tab or window, you can use the target attribute with the value “_blank”: