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:
<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:
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) orhref="pages/contact.html".
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.
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
Your turn
- Create a link to an external website with descriptive clickable text.
- Make a relative link to another page (about.html) on an imagined site.
- Rewrite a 'click here' link to have meaningful text describing its destination.
Key points
- A link is an element; href says where it goes; the content is the clickable text.
- Absolute links (https://...) go to other sites; relative links (about.html) go within yours.
- href="#id" jumps to a section on the same page.
- Write meaningful link text — 'pricing guide', not 'click here'.
Q&A · 0
Enrol to ask questions and join the discussion.
No questions yet — be the first to ask.