The <a> (anchor) tag is the browser's real navigation primitive: it gives links semantics, accessibility, and SEO behavior, and it avoids common button-vs-link pitfalls in production UIs.
What is the use of the <a> tag?
Direct answer
Use <a> when the user is navigating to another URL, document, or fragment target. In production, the common mistake is treating anchors and buttons as interchangeable: <a> preserves link semantics, open-in-new-tab behavior, browser history, and SEO, while <button> is for in-page actions.
<a href="/pricing">See pricing</a>
Use case | Example |
|---|---|
Internal page |
|
External site |
|
Same-page section |
|
Email link |
|
Phone link |
|
Download |
|
Security and accessibility essentials
<a href="https://example.com" target="_blank" rel="noopener noreferrer">
Open docs in new tab
</a>
- Use descriptive text like
Read pricing details, notClick here. - When using
target="_blank", addrel="noopener noreferrer". - Use
<a>for navigation and<button>for in-page actions.
Practical scenario
In a dashboard sidebar, each menu item should be an anchor to support navigation semantics, open-in-new-tab behavior, and browser history correctly.
Common pitfalls
- Using fake links (
href="#") for button-like actions. - Missing
relwithtarget="_blank". - Non-descriptive labels that hurt screen reader users.
<a> is a route sign. href is the destination address. No address means no navigation.
<a>is for navigation.hrefdefines destination.- Good link text and secure new-tab usage make links professional and accessible.
Use the relevant interview-question hub first, then move into a concrete study plan before targeted company sets.