Resources | Subject Notes | Information Communication Technology ICT
A hyperlink, often simply called a link, is a reference to another part of a document or a different document. It allows users to navigate quickly between different locations on the web or within a website. Hyperlinks are a fundamental part of web browsing and are essential for creating interconnected and navigable websites.
Hyperlinks are created using HTML code. They essentially tell the web browser where to go when a user clicks on a specific piece of text or an image. When a user clicks a hyperlink, the browser requests the resource specified by the link, and then displays that resource.
Hyperlinks are created using the <a>
tag (anchor tag). The href
attribute of the <a>
tag specifies the destination of the link. The destination can be:
mailto:
protocol)tel:
protocol)Here are some examples of how to create hyperlinks:
Linking to another website:
<a href="https://www.example.com">Visit Example Website</a>
Linking to a section within the same page:
<a href="#section2">Jump to Section 2</a>
In this case, there must be an <h2>
tag with the id="section2" somewhere on the page.
Linking to an email address:
<a href="mailto:info@example.com">Send an Email</a>
Linking to a phone number:
<a href="tel:+15551234567">Call Us</a>
By default, hyperlinks are typically displayed in blue and underlined. This visual cue helps users identify clickable elements on a webpage. The appearance of hyperlinks can be customized using CSS, but this is outside the scope of this topic.
Destination | HTML Code | Description |
---|---|---|
Another Webpage | <a href="URL">Text</a> | Links to a different website. |
Section within the same page | <a href="#section_id">Text</a> | Links to a specific section on the same page. Requires an ID attribute on the target section. |
Email Address | <a href="mailto:email@example.com">Text</a> | Opens the user's default email client with a new message addressed to the specified email. |
Phone Number | <a href="tel:+15551234567">Text</a> | Initiates a phone call on devices that support it. |
Understanding hyperlinks is crucial for creating well-structured and user-friendly websites. They enable navigation and provide access to a wealth of information.