← HTML tutorial

HTML

Links

The <a> (anchor) tag creates a clickable link. The href attribute sets where it points, another page, another site, or a spot further down the same page.

Example 1: absolute vs. relative links

<a href="https://mozilla.org">Absolute, full address</a>
<a href="/about">Relative, this same site's /about page</a>

An absolute link is a complete address to somewhere else on the internet. A relative link means "this same site's page at this path" with no domain written out, this is what you'd use for links within your own project, since it keeps working unchanged no matter what domain the site eventually gets deployed to.

Example 2: opening a link safely in a new tab

<a href="https://mozilla.org" target="_blank" rel="noopener">
  Opens in a new tab, safely
</a>

target="_blank" opens the link in a new tab. Always pair it with rel="noopener", without it, the page you linked to gains a small amount of programmatic access back to your original tab, a real (if narrow) security gap. It costs nothing to add and is worth making a permanent habit.

Try it yourself
Ready to go further?

These free tutorials are a preview, our Frontend Development cohort covers it in depth, with a real project and a cohort alongside you. Active

Enroll in Frontend Development
Don't miss out

Ready to build something real?

Create a free account to enroll in a track, and get notified the moment a cohort opens.

Create free account