HTML Anchor is a HTML element that creates a hyperlink to other web pages, files, locations within the same page, or any URL. The anchor element is represented by the <a> tag and the href attribute is used to specify the target URL.
Uses:
- Creating hyperlinks between web pages
- Jumping to specific sections within a web page
- Downloading files from the web
- Email link creation

Example 1: Link to another web page
<a href=”https://www.google.com”>Go to Google</a>
Example 2: Link to a specific section within the same web page
<a href=”#section1″>Go to Section 1</a>
…
<h2 id=”section1″>Section 1</h2>
Example 3: Download a file
<a href=”files/example.pdf” download>Download PDF</a>
Example 4: Email link
Input <a href=”mailto:example@email.com”>Send email</a>
Explanation
HTML anchors allow you to create hyperlinks within your HTML document, making it possible to navigate between different pages on the web, jump to specific sections within a page, download files, or even initiate an email client with a pre-written email.
The <a>
tag is the key component in creating HTML anchors. The href
attribute is used to specify the target URL for the hyperlink, which can be an absolute URL (e.g. https://www.example.com
) or a relative URL (e.g. /index.html
).
One common use of HTML anchors is linking to other pages on the web. For example, to link to Google, you would write the following HTML:
Input <a href=”https://www.google.com”>Go to Google</a
Another use of HTML anchors is to create in-page links that jump to specific sections of a page. This is accomplished by using the id
attribute on an HTML element (e.g. <h2>
, <p>
, <div>
) and then linking to that specific id
from within the anchor. Here’s an example:
<a href=”https://www.google.com”>Go to Google</a>
HTML anchors can also be used to download files from the web. To specify that a link should download a file, the download
attribute is used. For example:
Input Input <a href=”files/example.pdf” download>Download PDF</a>
Finally, HTML anchors can be used to initiate an email client with a pre-written email. This is done by using the mailto:
protocol in the href
attribute. For example:
<a href=”mailto:example@email.com”>Send email</a>
In conclusion, HTML anchors provide an essential function in HTML by allowing you to create hyperlinks between pages, jump to specific sections within a page, download files, and initiate email clients, making it possible to navigate the web and connect with others.
Leave a Reply