How to use the anchor tag in HTML

0
The <a> Tag in HTML

The <a> Tag in HTML

The <a> tag, also known as the anchor tag, is an essential element in HTML used to create hyperlinks. 

How to use the anchor tag in HTML
How to use the anchor tag in HTML

Syntax of the <a> Tag

<a href="URL">Clickable Text</a>

Attributes of the <a> Tag

  • href (Hyperlink Reference): Specifies the destination URL.
    Example:
    <a href="https://geekscodes.com">Visit Example</a>
    Output: Visit Example
  • target: Defines how the link opens:
    • _self: Opens in the same tab (default).
    • _blank: Opens in a new tab.
    Example:
    <a href="https://geekscodes.com" target="_blank">Open in New Tab</a>
    Output: Open in New Tab
  • rel: Provides the relationship between the current and linked pages.
    Common values:
    • nofollow: Tells search engines not to pass link equity.
    • noopener: Prevents the new page from accessing the window.opener property.
    Example:
    <a href="https://geekscodes.com" rel="nofollow noopener">Safe Link</a>
    Output: Safe Link
  • title: Adds extra information about the link, visible as a tooltip on hover.
    Example:
    <a href="https://geekscodes.com" title="Go to Example">Visit Example</a>
    Output: Visit Example
Tags

Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !
✨ Updates