Skip to content
KodeTrail

Camp 2 · Step 6 of 14

Links

The <a> element — linking to other sites, other pages, and places within the same page.

12 min+50 XP

Links are what make the web a web. One element does all of it: <a> (for "anchor") with its href attribute.

The anatomy

HTML
Live preview
  • href — the destination URL
  • The content between the tags — what the visitor clicks

Screen-reader users often jump from link to link, hearing only the link text. Compare:

<a href="/trails/python">Click here</a>              😕 here? where?
<a href="/trails/python">Start the Python trail</a>  😊 clear anywhere

Link text should describe the destination. "Click here" and "read more" are the "untitled_final_v2.doc" of the web.

Three kinds of destinations

HTML
Live preview

That third form pairs href="#some-id" with an element carrying id="some-id" — exactly how the table of contents on these lesson pages works.

Checkpoint

Which attribute holds a link's destination?

Checkpoint

Which is the best link text for accessibility?

What's next

Pictures! The img element, and why its alt text is non-negotiable.