The <a> Element in HTML

The <a> element is used to create links on a webpage. Links allow users to click and go to another webpage, another website, or even another section of the same page. Think of links as the connections of the web — they make the internet useful by helping users navigate easily between pages.

a element - Educodes

You can use the <a> tag to link to:

  • Websites
  • Other pages on your site
  • Email addresses
  • Downloads
  • Sections on the same page

To create a link, you use the href attribute to tell the browser where the link should go.

Understaning the layout of the <a> Element

Start tagElement contentEnd tag
<a href=”https://www.educodes.org”>View Educodes</a>

📘 Example Code

Below is an HTML example showing a heading and a link:

💡 This is what the code looks like inside an editor

<!DOCTYPE html> <html> <head> <title>Link Example</title> </head> <body> <h1>Useful Website</h1> <p>Click the link below to visit Google:</p> <a href=“https://www.google.com”>Go to Google</a> </body> </html>

🖥️ What This Will Look Like in a Browser

✅ Example output you would see on a webpage:

Click the link below to visit Google:

Go to Google

🧪 Time to Practise!

Now it’s your turn to create your own clickable link to Google.

Try this example first:

<a href="https://www.google.com">Visit Google</a>

What To Do

✅ Type the code above in the editor below
✅ Click Test Code to see the result
✅ Try changing the link text
✅ Try linking to a different website (example: https://www.youtube.com)

Tip 💡

Links are one of the most important parts of the web.
Use descriptive text so users know where the link goes — avoid generic text like “click here.”
Strong link text helps with usability and SEO. 🚀

HTML Editor

Live Preview

👉 Continue to the next lesson and learn how the <img> tag adds images to your webpage.


Educodes Logo

© Copyright 2024. | Educodes