Know and understand the function of a hyperlink
📚 21 Website Authoring – Hyperlinks
What is a Hyperlink?
A hyperlink (or link) is like a doorway that takes you from one webpage to another, or to a different part of the same page. Think of it as a magic bookmark that opens a new chapter when you click it. 🔗
How Does a Hyperlink Work?
When you click a link, your browser sends a request to the server that hosts the destination page. The server then sends the requested page back to your browser, which displays it. The link itself is defined by the href attribute inside an <a> tag. 🧩
Creating a Basic Hyperlink
- Choose the text you want to turn into a link.
- Wrap it with an
<a>tag. - Set the
hrefattribute to the URL you want to link to.
Example: <a href="https://www.example.com">Visit Example</a> ➡️ Visit Example
Link Attributes You Should Know
| Attribute | Purpose |
|---|---|
| href | Destination URL. |
| target | Where to open the link (_blank, _self, etc.). |
| title | Extra information shown on hover. |
| rel | Relationship to the linked page (e.g., nofollow). |
Best Practices for Hyperlinks
- Use clear, descriptive link text (avoid “click here”).
- Open external links in a new tab with
target="_blank"and addrel="noopener noreferrer"for security. - Check that all links work and lead to the correct page.
- Keep URLs short and readable when possible.
Quick Quiz
- What attribute tells the browser where to send the user when a link is clicked?
- Which attribute would you use to make a link open in a new tab?
- Why should link text be descriptive?
Answers: 1️⃣ href 2️⃣ target="_blank" 3️⃣ Helps users know where they’re going and improves accessibility. ??
Revision
Log in to practice.
3 views
0 suggestions