HTML <a> href Attribute

Last Updated : 6 May, 2026

The HTML <a> tag uses the href attribute to define the destination URL of a hyperlink, making it clickable for navigation.

  • href specifies the URL the link points to.
  • It is required for the <a> tag to function as a hyperlink.
  • Used to navigate between pages or resources.

Syntax

<a href="URL"> Link text </a>

Attribute Values

  • Absolute URL: It points to another website.
  • Relative URL: It points to a file within a website.
  • Anchor URL: It points to an anchor within a page.

Example: This example demonstrates the use of href attribute in <a> element.

HTML
<!DOCTYPE html>
<html>

<head>
    <title>HTML a href Attribute</title>
</head>

<body>
    <h1>GeeksforGeeks</h1>

    <h2>HTML a href Attribute</h2>

    <a href="https://www.geeksforgeeks.org/">
        Click Here to Open in Same Tab
    </a>
    <br>
    <a href="https://www.geeksforgeeks.org/html-tutorial/" 
        target="_blank">
        Click Here to Open in a New Tab
    </a>
</body>

</html>

Output

Supported Browsers

  • Chrome 1
  • Edge 12
  • Firefox 1
  • Opera 15
  • Safari 1
Comment