Hyperlink

A hyperlink, commonly referred to as a link, is a reference in a hypertext document that points to another document or resource. When a user clicks on a hyperlink, the web browser navigates to the linked resource. Hyperlinks are a fundamental element of the World Wide Web, enabling users to easily navigate between web pages and other resources.

Hyperlinks are created using the <a> (anchor) tag in HTML. The href attribute of the <a> tag specifies the URL of the destination resource. Links can point to various types of resources, including web pages, images, files, and other types of documents. Hyperlinks can also be used for navigation within the same document.

Example of a Hyperlink:

<a href="https://www.example.com">Visit Example.com</a>

In this example, clicking on the text “Visit Example.com” will navigate the user to the URL “https://www.example.com”.

Attributes of the <a> Tag:

Examples:

  1. Basic Hyperlink:

    <a href="https://www.example.com">Visit Example.com</a>
    

    This creates a clickable link that navigates to “https://www.example.com”.

  2. Hyperlink with target Attribute:

    <a href="https://www.example.com" target="_blank">Open Example.com in a New Tab</a>
    

    This link opens the destination URL in a new browser tab.

  3. Hyperlink with title Attribute:

    <a href="https://www.example.com" title="Example Website">Visit Example.com</a>
    

    This link includes a tooltip that displays “Example Website” when hovered over.

  4. Internal Link (within the same page):

    <a href="#section1">Go to Section 1</a>
    
    <h2 id="section1">Section 1</h2>
    <p>This is Section 1 of the document.</p>
    

    This creates a link that navigates to a different section within the same page, identified by the id attribute.