• This topic is empty.
Viewing 1 post (of 1 total)
  • Author
  • #2807


    The <a> element in HTML stands for “anchor” and is used to create hyperlinks. These hyperlinks allow users to navigate from one web page to another, or to different parts of the same web page. The primary attribute of the </a><a> element is href, which stands for “hyperlink reference” and specifies the URL of the page or resource that the link points to.

    Basic Structure:

    Here’s the basic structure of an <a> element:

    <a href="URL">Link Text</a>
    • <a>: The opening anchor tag.
    • href="URL": The href attribute specifies the destination URL. This can be an absolute URL (a full web address) or a relative URL (a path relative to the current page).
    • Link Text: The clickable text or content that appears as the link.
    • </a>: The closing anchor tag.


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

    In this example, “Visit Example.com” is the link text. When clicked, it will take the user to `https://www.example.com`.

    Common Attributes:

    • href: Specifies the URL of the page the link goes to.
    • target: Specifies where to open the linked document. For example, target="_blank" opens the link in a new tab or window.
    • title: Provides additional information about the link, often displayed as a tooltip when the user hovers over the link.
    • rel: Specifies the relationship between the current document and the linked document. For example, rel="noopener noreferrer" is used when using target="_blank" to enhance security and performance.

    Additional Examples:

    1. Linking to another web page:
    <a href="https://www.google.com">Go to Google</a>
    1. Linking to a different part of the same page (using an ID):
    <a href="#section2">Jump to Section 2</a>
    <h2 id="section2">Section 2</h2>
    1. Linking to an email address:
    <a href="mailto:someone@example.com">Send Email</a>
    1. Opening a link in a new tab:
    <a href="https://www.example.com" target="_blank" rel="noopener">Open Example in New Tab</a>
    1. Linking to a downloadable file:
    <a href="/files/example.pdf" download="">Download PDF</a>

    The <a> element is versatile and essential for creating an interconnected web by linking documents and resources together. 

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.
Scroll to Top