Reference · Beginner
The anchor element
Create crawlable, keyboard-accessible links with meaningful destination text, valid URLs, and safe external-link behavior.
- Author
- Editorial team
- Reviewer
- Publication review pending
- Review tier
- annual
Definition
An a element with an href creates a hyperlink to another resource or a
location within a resource.
Syntax
<a href="/workshops.html">Browse upcoming workshops</a>
Important attributes
href supplies the destination. hreflang, type, and download can add
information for specific links. Use target="_blank" only for a justified
experience and explain unexpected new windows.
Accessibility
Link text should identify purpose without depending on nearby “click here”
phrases. Do not remove focus styles. An anchor without href is not a normal
keyboard link.
Common misuse
Do not use a link to toggle local state when a button is appropriate. Avoid JavaScript URLs and invalid nesting of interactive controls.