HTML Tags

HTML <a> Tag

The <a> tag, also known as the anchor tag, is used to create hyperlinks in HTML.
It allows users to navigate between web pages, jump to specific sections, download files, or even send emails using mailto: links.
It is one of the most important elements for web navigation and interconnectivity.

Syntax

html

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

Attributes

AttributeDescription
hrefSpecifies the destination URL or resource to link to.
targetDefines where to open the linked document (_self, _blank, _parent, _top).
titleDisplays additional information when the user hovers over the link.
downloadInstructs the browser to download the linked file instead of navigating to it.
relSpecifies the relationship between the current document and the linked document (e.g., nofollow, noopener, noreferrer).
idUnique identifier for the link.
classCSS class for styling the link.
styleInline CSS styling for the link.

Example

html

<!DOCTYPE html>
<html>
<head>
  <title>Anchor Tag Example</title>
  <style>
    a {
      color: #29AB87;
      text-decoration: none;
      font-weight: bold;
    }
    a:hover {
      color: #1c7a63;
      text-decoration: underline;
    }
  </style>
</head>
<body>
  <h1>HTML <a> Tag Example</h1>

  <p>
    Visit our official website:
    <a href="https://html5andcss3.org" target="_blank" title="Visit HTML5 and CSS3 Official Site">
      HTML5 and CSS3
    </a>
  </p>

  <p>
    Download a sample PDF file:
    <a href="https://ik.imagekit.io/html5andcss3/lesson-samples/sample.pdf" download="sample.pdf">Download PDF</a>
  </p>

  <p>
    Send us an email:
    <a href="mailto:info@html5andcss3.org">info@html5andcss3.org</a>
  </p>

  <p>
    Jump to a section on this page:
    <a href="#about">Go to About Section</a>
  </p>

  <h2 id="about">About Section</h2>
  <p>This section explains the working of the anchor tag in HTML.</p>
</body>
</html>

Output

Browser Output

html

Use our TryIt Editor to see the output.

Browser Support

Chrome
Edge
Firefox
Safari
Opera
IE9+
YesYesYesYesYesYes

The links appear as clickable text, styled according to your CSS.
Hover effects, file download, and email actions work as expected.

Notes

  • Always use target="_blank" carefully - add rel="noopener noreferrer" for security.
  • The <a> tag can link to internal elements using IDs (e.g., href="#section").
  • You can turn any element (like <img> or <button>) into a link by wrapping it with <a>.
  • Use the download attribute for files you want the user to save instead of opening.
  • mailto will only work on the device which has default mail client has been configured.

Conclusion

The <a> tag enables hyperlinking and navigation, connecting web pages, files, and resources seamlessly.
It is the backbone of web navigation, making content interactive and interconnected.