HTML Links

What Is a Link?

HTML links use the <a> (anchor) tag to allow users to click and go to another page, section, or resource.

<a href="https://example.com">Visit Site</a>

Basic Syntax

The href attribute defines the destination. The link text is what users click.

<a href="https://example.com">Click here</a>

Opening Links in a New Tab

Use target="_blank" to open the link in a new browser tab.

<a href="https://example.com" target="_blank">Open in new tab</a>

Internal vs External Links

  • Internal: Links within your site
  • External: Links to other websites
<a href="/contact.html">Contact</a>
<a href="https://wikipedia.org">Wikipedia</a>

Linking to Email or Phone

Use mailto: or tel: to create interactive links:

<a href="mailto:info@example.com">Email Us</a>
<a href="tel:+1234567890">Call Us</a>

Download Links

Use the download attribute to trigger a file download instead of navigating to the file.

<a href="files/guide.pdf" download>Download PDF</a>

Practice Prompt

Create 3 links:

  • One to https://www.google.com (open in new tab)
  • One to a local file named about.html
  • One that downloads resume.pdf
<a href="https://www.google.com" target="_blank">Google</a>
<a href="about.html">About Page</a>
<a href="resume.pdf" download>Download Resume</a>

Need Help?

Ask the AI if you need help understanding or want to dive deeper in any topic