Anchor links
Learn to link to other pages with <a> and the href attribute.
What is the anchor tag for?
The tag that lets you move from one page to another is <a>, also called an anchor. Any text wrapped in an <a> tag becomes clickable, and the browser draws it as a link.
The destination address is set with the href attribute. While the headings and paragraphs from earlier lessons present information, the <a> tag makes the page interactive.
How to choose anchor text?
The text between the <a> tags is called anchor text. It should describe what the link is about. Instead of vague phrases like 'click here', prefer clear text such as 'See the menu' or 'Buy tickets'.
Clear anchor text helps both readers and screen readers, and search engines use it to understand the link's context.
Exercise Add an anchor link to a cafe page.
In the skeleton below, create a link to the menu page using an <a> tag. The anchor text should be "See the menu".
Show example solution
<p>Welcome to Galata Cafe.</p>
<a href="menu.html">See the menu</a>
Links bring a page to life
In this lesson you saw that the <a> tag turns text into a link. The href attribute sets the target, while the text between the tags provides context. Choosing clear anchor text keeps the link understandable and accessible to screen readers.
In the next lessons we will look at the different forms these addresses can take — absolute, relative, and in-page — step by step.
Test yourself
-
Which attribute sets the destination address of a link?
- href
- src
- link
- name
Show answer
href — Correct. href carries the link's target address.
-
Complete the city guide link.
<a href="____">Istanbul tour</a>Show answer
<a href="https://sehir-rehberi.example/istanbul">Istanbul tour</a> -
Match the anchor link parts.
- <a>
- Anchor tag
- href
- Target address attribute
- anchor text
- Clickable text
- link
- Transition between pages