Published by Patrick Mutisya · 8 days ago
Students will be able to create hyperlinks from text and images that:
<a> ElementThe anchor element creates a hyperlink. Its most important attributes are:
| Attribute | Purpose | Example \cdot alue |
|---|---|---|
href | Destination of the link | page2.html, #section3, mailto:user@example.com |
target | Where the linked document will open | self, blank, myWindow |
title | Optional tooltip text | "Go to the contact page" |
First create a bookmark using the id attribute, then link to it with a hash (#) followed by the id.
<h2 id="chapter3">Chapter 3 – Advanced Topics</h2>
...
<a href="#chapter3">Jump to Chapter 3</a>
Assume the file about.html resides in the same folder as the current page.
<a href="about.html">About Our School</a>
Use the full URL, including the protocol (http:// or https://).
<a href="https://www.bbc.com" target="_blank">BBC News</a>
The mailto: scheme opens the default e‑mail client with a pre‑filled address.
<a href="mailto:info@example.com?subject=Inquiry">Email Us</a>
The target attribute determines the browsing context.
target="_self" or omit the attribute.target="_blank".Examples:
<a href="page2.html" target="_self">Open in same window</a>
<a href="https://www.wikipedia.org" target="_blank">Open in new tab</a>
<a href="help.html" target="helpWindow">Open in named window</a>
<a href="faq.html" target="helpWindow">Another link to same named window</a>
Wrap the <img> element (or a placeholder figure) inside an <a> tag.
<a href="..."><img src="..." alt="..."></a> structure.
<a href="gallery.html" target="_blank">
<!-- Replace the comment with an actual <img> element when building the page -->
</a>
| Link Purpose | Example href | Target Attribute |
|---|---|---|
| Bookmark on same page | #section2 | _self (default) |
| Local page in same folder | contact.html | _self |
| External website | https://www.google.com | _blank |
| E‑mail address | mailto:support@example.com | _self |
| Named window (e.g., help) | help.html | helpWindow |
top at the very beginning of the page.resources.html in a new tab.admin@school.org with the subject “Website feedback”.www.example.com instead of https://www.example.com).# when linking to a bookmark.target="_blank" without considering accessibility – always provide a clear indication that a new window/tab will open.<a href="page.html">Link text</a>
<a href="page.html" target="_blank">Link</a>
<a href="page.html" target="myWin">Link</a>
<a href="#section">Jump to section</a>
<a href="mailto:name@domain.com">Email</a>
<a href="https://example.com">External site</a>