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
| Attribute | Description |
|---|---|
| href | The URL or fragment the link points to. |
| target | Where to open the link: _self (default), _blank, _parent, _top. |
| rel | Relationship of the target, e.g. noopener, noreferrer, nofollow. |
| download | Prompts the browser to download the resource instead of navigating to it. |
| hreflang | The language of the linked document. |
| type | The 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.
