# `<a>`

> The `<a>` HTML element creates a hyperlink, enabling users to navigate to other pages, resources or sections within the same document.

## How do I create an accessible link with the a tag in HTML?

The element that creates a hyperlink to another page or resource. It can link to an external site, another page within the same site or a specific section within a page using the `href` attribute.

- Topic: Links
- Type: tag
- Browser support: Chrome 1+, Chrome Android 18+, Edge 12+, Firefox 1+, Firefox Android 4+, Safari 1+, Safari iOS 1+

## Example

Wrong:

```html
<a href="#" onclick="openMenu()">
  Menu
</a>
```

Right:

```html
<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 an `href`; 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.

## Related cards

- [link](https://wonderium.dev/a11y/link.md)
- [`<button>`](https://wonderium.dev/html/button.md)
- [:link](https://wonderium.dev/css/link.md)
- [:focus-visible](https://wonderium.dev/css/focus-visible.md)
- [URL](https://wonderium.dev/web/url.md)

---

- Level: [HTML](https://wonderium.dev/html.md)
- HTML version: https://wonderium.dev/html/a
- Last updated: 2026-11-25
