The <a> (anchor) element creates a hyperlink. With href, it points to a page, file, email address, phone number, or a place in the same document.
Put clear destination text inside the tag. Use target, rel, and download when you need a new tab, link relationship, or file save. For actions that are not navigation, use <button> instead.
Baseline · Widely available.
Not deprecated. Core hyperlink support has been stable across browsers since about July 2015 (and much earlier in practice).
Deprecated attributes.
Do not use charset, coords, name, rev, or shape on <a>. Prefer id for in-page targets and <area> for image maps.
Experimental extras.
attributionsrc (Attribution Reporting) and interestfor (interest invokers) are newer and have limited support — skip them until you need those APIs.
Syntax
HTML Syntax
syntax.html
<a href="url">link text</a>
Both start and end tags are required. Nested interactive content (another <a>, buttons, etc.) is not allowed. Without href, the element is not a link.
Same-origin files honor download best; cross-origin often ignores it.
How It Works
Point href at a file the browser can fetch (image, PDF, etc.).
Add download. Alone, the browser picks a name; with a value, that name is suggested.
Same-origin first. Cross-origin URLs often ignore download and navigate instead.
Say what happens. Link text like “Download logo PNG” sets clear expectations.
Edge Cases & Pitfalls
Most link bugs come from weak text, fake buttons, or surprising new tabs.
a11y
Avoid “click here”
Screen reader users often browse a list of links. Text must make sense out of context.
semantics
Do not fake buttons with href="#"
Copying, middle-click, and no-JS all break. Use <button> for actions.
security
target="_blank" needs care
Warn in link text. Prefer explicit rel="noopener" (modern browsers also apply it implicitly for _blank).
nesting
No nested links
An <a> cannot contain another interactive control or nested <a>.
privacy
ping sends tracking POSTs
Space-separated URLs get a PING body when the link is followed. Support and user controls vary; do not rely on it alone.
Compatibility
Browser Support
The <a> element is core HTML in every browser. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
<a>
Widely available since about July 2015 (and long before as HTML anchors). Chrome, Firefox, Safari, Edge, and Opera all support hyperlinks fully. Some attributes such as ping or download on cross-origin URLs vary.
98%Global support (approx.)
Google ChromeAll
Full support
Mozilla FirefoxAll
Full support
Apple SafariAll
Full support
Microsoft EdgeAll
Full support
OperaAll
Full support
Samsung InternetAll
Full support
Internet ExplorerAll
Supported
<a>Widely supported
Bottom line: Safe to use everywhere for navigation. Treat download cross-origin behavior, ping, and experimental attributes as progressive extras.
Remember
Key Takeaways
Role:<a href="…"> creates real navigation — not a stand-in for buttons.
Text: describe the destination; avoid empty or “click here” links.
Schemes: pages, #id, mailto:, tel:, and downloads are all valid destinations.
New tabs: warn users; pair target="_blank" with clear rel.
One line: a good <a> has a real href and link text that names the destination.
UA style
Default CSS Settings
Browsers style links in the user-agent stylesheet. Exact colors use system keywords such as LinkText today; the classic idea looks like this:
Override carefully: keep a clear visited/unvisited difference when it helps, and never remove focus styles for keyboard users.
Frequently Asked Questions
The a (anchor) element creates a hyperlink to a web page, file, email address, phone number, or a section on the same page when you set the href attribute.
For a real, activatable link, yes — include href. Without href, the element is not a link (its implicit ARIA role becomes generic). Prefer a button for actions that are not navigation.
Use target="_blank". Modern browsers treat that as implicitly noopener. Adding rel="noopener noreferrer" is still a clear, portable habit, and warn users in the link text that a new tab opens.
Set href to a fragment that matches an element id, for example href="#pricing" jumps to <section id="pricing">. href="#top" or href="#" jumps to the top of the page.
Use href="mailto:[email protected]" for email and href="tel:+18005551234" for phone numbers. On capable devices, the OS opens the mail or dialer app.
No. It works reliably for same-origin URLs, blob:, and data: URLs. Cross-origin links often ignore download and navigate normally unless the server sends Content-Disposition.