<a>
Example
<a href="#" onclick="openMenu()">
Menu
</a><button type="button" onclick="openMenu()">
Menu
</button>An action that does not navigate is a <button>, which works with keyboard and screen readers by default.
Common mistakes
- Using
<a href='#'>with a click handler instead of a<button>. - Writing vague link text like 'here', which makes no sense out of context.
Key points
- Every
<a>used as a link has anhref; actions without navigation use<button>. - Link text describes the target, not 'click here' or 'read more'.
- Links that open a new tab say so in the text or accessible name.
- Icon-only links have an accessible name from hidden text or
aria-label.
Interview questions
Do I still need rel='noopener' with target='_blank'?
Modern browsers apply noopener by default for target='_blank'. Adding rel='noopener' is still harmless and covers older browsers.
Can I put block elements inside an a tag?
Yes, <a> can wrap blocks like <div> or headings, as long as it contains no other interactive content such as buttons or links.