HTML Tags

HTML <a> Tag

The <a> (anchor) tag creates a hyperlink to web pages, files, email addresses, locations on the same page, or anything else a URL can address.


What is the <a> tag?

The <a> element defines a hyperlink. Its most important attribute is href, which holds the destination URL. The text, image, or other content between the opening and closing tags becomes the clickable link. By default links are inline elements shown underlined and in a distinct colour.

Syntax

<a href="https://example.com">Link text</a>

Complete example

<!DOCTYPE html>
<html lang="en">
  <body>
    <a href="https://myinternships.in">External site</a>
    <a href="mailto:hello@example.com">Send email</a>
    <a href="#section2">Jump to section 2</a>
    <a href="report.pdf" download>Download PDF</a>
    <a href="https://example.com" target="_blank" rel="noopener noreferrer">Open in new tab</a>
  </body>
</html>

Attributes

AttributeDescription
hrefThe URL or fragment the link points to.
targetWhere to open the link: _self (default), _blank, _parent, _top.
relRelationship of the target, e.g. noopener, noreferrer, nofollow.
downloadPrompts the browser to download the resource instead of navigating to it.
hreflangThe language of the linked document.
typeThe MIME type of the linked resource.
⚠️

When using target="_blank", add rel="noopener noreferrer" to prevent the new page from accessing your window object, closing a common security hole.

The <a> tag is supported in all browsers. An anchor with no href is a placeholder link and is not treated as a hyperlink.

Ready to use your HTML skills?

Find web development internships and fresher jobs across India.

Browse Web Dev Internships