Level:Beginner

HTML Links

The <a> (anchor) element creates hyperlinks—links to other pages, sections, files, email addresses, or phone numbers.

What is a Link?

  • A link is created using <a> with the href attribute.
  • href tells the browser where to go.
  • Links can be external (full URL), internal (relative URL), or page jumps (like #section).

Important Attributes

  • href: destination (URL, mailto:, tel:, or #id)
  • target="_blank": opens in a new tab
  • rel="noopener noreferrer": security best practice when using target="_blank"
  • Use clear link text (avoid “click here”). Good: Read the HTML guide.

Links Example

HTML Links Examplehtml
<!-- Basic link -->
<a href="https://example.com">Visit Example</a>

<!-- Open in new tab (security best practice: rel) -->
<a href="https://example.com" target="_blank" rel="noopener noreferrer">
  Open in new tab
</a>

<!-- Internal link (relative URL) -->
<a href="/tutorials/html">Go to HTML tutorials</a>

<!-- Email & phone links -->
<a href="mailto:hello@w3camp.com">Email us</a>
<a href="tel:+12025550123">Call us</a>

<!-- Jump link (same page) -->
<a href="#tips">Skip to tips</a>

Preview

localhost:3000
Loading preview...