HTML Anchor Tag
What is an HTML Anchor Tag?
The <a> tag (anchor tag) is used to create hyperlinks that link one page to another, go to external websites, jump to sections, or even send emails.
Syntax of Anchor Tag
<a href="URL">Link Text</a>
The href attribute defines the link destination.
HTML Anchor Tag Examples
External Link
<a href="https://www.google.com">Visit Google</a>
Internal Link (Another Page on Same Website)
<a href="about.html">Go to About Page</a>
Open Link in New Tab
<a href="https://www.wikipedia.org" target="_blank" rel="noopener noreferrer">Open Wikipedia in New Tab</a>
Link to Email
<a href="mailto:example@example.com">Send Email</a>
Phone Call Link
<a href="tel:+1234567890">Call Us</a>
Anchor Link to Section (Jump Link)
First, you need a target with an id:
<h2 id="contact">Contact Section</h2>
Then link to it:
<a href="#contact">Jump to Contact Section</a>
Download a File
<a href="file.pdf" download>Download PDF</a>
Best Practices for <a> Tags
- Always include title for accessibility
- Use target="_blank" with rel="noopener noreferrer" for security
- Make link text meaningful — avoid "Click Here"
- Use descriptive text that indicates where the link goes
- Ensure links have good color contrast for visibility
- Consider adding visual indicators for external links