Introduction
The anchor tag lets you create links to other pages or places. It helps people move around the web easily.
The anchor tag lets you create links to other pages or places. It helps people move around the web easily.
<a href="URL">Link text</a>
href attribute holds the link address.<a> and </a> is what users click.<a href="https://example.com">Visit Example</a>
<a href="#section1">Go to Section 1</a>
<a href="mailto:someone@example.com">Send Email</a>
<a href="file.pdf" download>Download PDF</a>
This page has three anchor links: one to an external site opening in a new tab, one to jump to a section on the same page, and one to open an email program.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Anchor Tag Example</title> </head> <body> <header> <nav> <a href="https://www.wikipedia.org" target="_blank" rel="noopener noreferrer">Go to Wikipedia</a> </nav> </header> <main> <section id="info"> <h2>Information Section</h2> <p>This is a section you can jump to.</p> <a href="#top">Back to top</a> </section> </main> <footer> <p>Contact us: <a href="mailto:contact@example.com">contact@example.com</a></p> </footer> </body> </html>
Use target="_blank" to open links in a new tab safely with rel="noopener noreferrer".
Make sure link text clearly describes where the link goes for better accessibility.
Use semantic HTML elements like <nav> for navigation links.
The anchor tag <a> creates clickable links.
The href attribute sets the link destination.
Links can go to other pages, parts of the same page, emails, or files.
<a> tag do in HTML?href inside the <a> tag.href and link text correctly. Other options use wrong attributes or tags.<a href="#section2">Go to Section 2</a>
<h2 id="section2">Section 2</h2>
<a href="www.example.com">Example</a>
mailto: protocol in the href attribute to open the email client.mailto:contact@example.com correctly. <a href="email:contact@example.com">Send Email</a> uses wrong protocol 'email:', while others lack the protocol or use incorrect formats like 'mailto://'.Pass the test and this pattern moves unknown