HTML Tutorial · HTML Basics · Lesson 6 of 34

HTML Links

Create links with <a>, absolute and relative URLs, new tabs and page anchors.

The anchor element

<a href="..."> creates a hyperlink. The href can be:

  • an absolute URL: https://example.com/page
  • a relative path: about.html, ../images/logo.png, /contact
  • a fragment: #pricing (jumps to the element with id="pricing")
  • mailto: and tel: links
Example 1Try it yourself
<p><a href="https://developer.mozilla.org/" target="_blank" rel="noopener">MDN Web Docs</a> (new tab)</p>
<p><a href="#faq">Jump to the FAQ</a></p>
<p><a href="mailto:[email protected]">Email us</a> or <a href="tel:+442079460000">call us</a></p>
<div style="height: 160px"></div>
<h2 id="faq">FAQ</h2>
<p>You jumped here with a fragment link.</p>

Opening in a new tab

target="_blank" opens a new tab. Modern browsers add rel="noopener" automatically, but writing it explicitly is still common.

Link text should make sense on its own — "Read the pricing guide", not "click here". It helps screen-reader users (who often jump from link to link) and search engines, which use link text to understand the target page.

Test yourself

Which attribute holds a link's destination?

  1. src
  2. href
  3. link
  4. url
Show answer

Answer: href