HTML <a> Element
The <a> element, also called the anchor element, creates a hyperlink when the href attribute is included. A link can point to another web page, a file, an email address, a location within the current page, or another valid URL.
Syntax
<a href="URL">Link text</a>
The opening and closing tags are both required.
Attributes
The <a> element supports the global HTML attributes and the following element-specific attributes:
| Attribute | Description |
|---|---|
href |
Specifies the URL or destination of the hyperlink. |
target |
Specifies where the linked resource will open. |
download |
Indicates that the linked resource should be downloaded instead of opened normally. |
ping |
Specifies one or more URLs that are notified when the link is followed. |
rel |
Describes the relationship between the current document and the linked resource. |
hreflang |
Provides the language of the linked resource. |
type |
Provides a hint about the media type of the linked resource. |
referrerpolicy |
Controls how much referrer information is sent when the link is followed. |
The target, download, ping, rel, hreflang, type, and referrerpolicy attributes should only be used when the href attribute is present.
Example
The following example creates a link to another website:
<a href="https://www.example-web.site/">Visit Example Web Site</a>
The browser displays:
Usage Notes
When the href attribute is present, the <a> element represents a hyperlink. Without href, it does not create an active link and instead acts as a placeholder for link content.
Link text should clearly describe the destination or purpose of the link. Avoid vague text such as click here when more descriptive wording can be used.
An <a> element must not contain another interactive <a> element.
Accessibility
Use descriptive link text that makes sense when read on its own. This helps people using screen readers and also makes links easier for all visitors to scan and understand.
Links should remain visually distinguishable from surrounding text and should provide a visible focus indicator when reached with the keyboard.
Browser Support
Baseline: Widely available indicates a feature has been supported by core browsers for at least 30 months. At this stage, the feature is considered stable and safe for most websites to use without needing to worry about compatibility issues or fallbacks, as it is supported by the vast majority of users' devices and browser versions.
For detailed browser compatibility information, see Can I Use: HTML <a> Element .
Some individual attributes and newer hyperlink features may have different levels of browser support.
Related Elements
<area> - Creates a hyperlink or active area within an image map.
<link> - Defines a relationship between the current document and an external resource.
<nav> - Represents a section containing navigation links.
