HTML · Unit 1: Your first web page · Lesson 5 of 5
Links
The <a> element makes a link.
Opens this lesson in Code Academy. Lessons open one after another, and each unit opens when you pass the checkpoint quiz before it (you can take a checkpoint early to skip ahead). If this lesson is not open yet, the button shows you its unit on your map.
The idea
The <a> element makes a link. Its href attribute holds the address: <a href="https://example.com">Example</a>.
An attribute adds information to an opening tag. It is written name="value", with the value in quotes.
Link text should say where the link goes. "Opening hours" helps everyone, including people using screen readers. "Click here" does not.
Worked example
HTML
<p>Read the <a href="https://example.com/rules">park rules</a> before you visit.</p>
Links in the preview are shown but never followed.
Key terms
- Link
- An <a> element with an href. Its text should say where it goes.
- Attribute
- Extra information in an opening tag, written name="value", like href="https://example.com".
Practise it in Code Academy
It has 4 exercises (multiple choice, fill in the blank, fix the broken code and write code from a prompt) and takes about 6 minutes. Every answer is checked as you go, and feedback names the exact mistake. Hints and the solution are there if you get stuck.
Every lesson is free: no ads, no lives and no paywall.