Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

1.4 KB
Raw Blame
Links that open in a new browser tab or window (`target="_blank"`) can be confusing for users, especially for those using assistive technologies. To ensure accessibility, we need to provide clear context so that all users understand that the link will open in a new tab.

## Why `_blank` Links Need Accessible Hints

- Users may lose track of their current page if a link opens in a new tab unexpectedly.
- Screen reader users may not be aware of the new tab unless it is explicitly communicated.
- Providing a description improves usability and ensures compliance with WCAG guidelines.

---

## Recommended Attributes

To make `_blank` links accessible, we rely on:

- **`aria-describedby`**: Points to a hidden element describing the new tab behavior.
- **`aria-label`** *(optional)*: Can include context about the link and new tab behavior.
- **`title`** *(optional)*: Provides a tooltip for sighted users.

---

## Technical notes

We implemented a stimulus controller called `external-links` which automatically applies an `aria-describedby` attribute to all links that set `target='_blank'`. Therefore, we included a single hidden element in the `base.html` which all `_blank` links can reference:

```erb
<span id="open-blank-target-link-description" class="sr-only">
  <%= I18n.t("open_link_in_a_new_tab") %>
</span>
```

By that all external links automatically read out to the screen reader users that they open a new tab.