HTML Essentials

Lesson 11 of 32

Links

Links are what make the web a web — they connect pages to each other. The link element, <a>, is one of the most important in all of HTML. Master it and you can send visitors anywhere.

The anchor element

A link is an <a> (anchor) element. Its href attribute says where the link goes, and the content between the tags is the clickable text:

Try it Yourself
Loading editor…
Result
  • <a> — the anchor (link) element.
  • href="https://example.com" — the hypertext reference: the destination.
  • Visit Example — the visible, clickable text.

Without href, an <a> isn't really a link — the href is what makes it go somewhere.

Links can wrap anything

The clickable content doesn't have to be plain text — it can be an image, or text with emphasis inside it:

Try it Yourself
Loading editor…
Result

Absolute vs relative links

Two kinds of destination:

  • Absolute — the full web address, starting with https://. Used to link to other websites: href="https://google.com".
  • Relative — a path relative to the current page, used to link within your own site: href="about.html" (a page in the same folder) or href="pages/contact.html".
Try it Yourself
Loading editor…
Result

The third one — href="#section2" — jumps to a part of the same page (an element with that id). Links do more than cross sites; they navigate within them too.

Write meaningful link text

The clickable text should describe where the link goes. "Click here" is poor — it tells the reader (and screen readers, which list links) nothing. "Read our pricing guide" is good — it says what you'll get.

Try it Yourself
Loading editor…
Result

The mistake beginners make

Forgetting the href (so the link goes nowhere), mistyping the destination, or using unhelpful link text like "click here." Also, mixing up absolute and relative — using a bare example.html when you meant an external site (which needs the full https://).

Your turn

Try it Yourself
Loading editor…
Result

Your turn

  1. Create a link to an external website with descriptive clickable text.
  2. Make a relative link to another page (about.html) on an imagined site.
  3. Rewrite a 'click here' link to have meaningful text describing its destination.

Key points

Q&A · 0

Enrol to ask questions and join the discussion.

No questions yet — be the first to ask.