A link is what lets visitors move from one page to another. The a element becomes a hyperlink when it has a useful href destination. The important question is always where the link leads and whether the person reading the page can predict it.
What You Need to Know
Choose link text that says where it goes. A link to a new page is different from a button that performs an action on the current page.
A navigation landmark is useful when it contains a substantial group of links, not every isolated link on a page.
Example: See It in Action
Take a look at this small piece of HTML. You can use it in a practice document and change the text to make it your own.
This is a short HTML fragment. To try it as a webpage, put it inside the body element of a complete HTML document.
<nav aria-label="Main navigation">
<a href="index.html">Home</a>
<a href="about.html">About</a>
<a href="contact.html">Contact</a>
</nav>
Let’s Understand the Example
- An a element becomes a working link when it has an href. Its visible text should tell readers where they will go.
- Nav identifies a major collection of navigation links.
- Aria-label supplies an accessible name when a visible label is unavailable or inadequate.
- Href contains the destination of a link. A value starting with # points to an id on the same page.
The first example link points to index.html. Check whether that destination exists relative to the document. A link changes where readers go; it does not perform an action such as saving a form.
What Should You See?
You should see a link named “Home”. Selecting it leads to index.html when that destination exists. Try it with the mouse and the keyboard.
Imagine this link is read out of context. Would its text still explain the destination? Rename unclear links before trying to make them look nicer with CSS.
Try It Yourself
- Add a link to a portfolio page using its actual page name as the text.
- Save your changes, open or refresh the page, and compare the result with the original example.
- Tell a friend what your change did. If you are not sure, undo it, refresh the page, and compare.
Common Beginner Mistakes
- Writing Click here for every link, so readers cannot tell destinations apart.
- Avoid dead links, empty href values and clickable-looking text without a real destination.
Key Takeaways
- A link is what lets visitors move from one page to another.
- An a element becomes a working link when it has an href. Its visible text should tell readers where they will go.
- A navigation landmark is useful when it contains a substantial group of links, not every isolated link on a page.