Part of the Link ecosystem · 35 projects
This module adds a widget to Drupal's link field, allowing you to set attributes like ID, class, and target for links. It also extends this functionality to menu links.
Overview
Link attributes widget provides an additional widget for the link field found in Drupal core.
The widget allows users to set attributes on their link.
In addition the module alters the default menu link content link field to use this widget, allowing menu links to have attributes too
Features
Supported attributes include
- id
- class
- name
- target
- rel
- accesskey
- aria-label (since 8.x-1.3)
- title (since 8.x-1.7)
- Linkit support (since 2.1.0) - via a submodule
Should I use the 1.x or 2.x version?
New installs should use the 2.x version. Existing sites on the 1.x version are encouraged to update to the 2.x stream. There are no breaking changes, but 2.x splits the automatic use of the widget for menu links into a submodule.
Installation and configuration overview
- Enable the module like normal
- If using the 1️⃣.x branch, It will immediately take effect on menu link content entities.
- If using the 2️⃣.x branch, enable the Link Attributes Menu Link Content sub module and It will immediately take effect on menu link content entities.
- For other link fields, edit the widget using 'Manage form display' and select the 'Link (with attributes)' widget
- Read the documentation for how to modify defaults and add custom attributes.
- Optionally enable the Linkit Attributes sub-module to make an additional Linkit (with Attributes) widget available.
Limitations
Note that some menu links are provided by modules. These links do not have a link field, and cannot have attributes added. For example the 'Contact' link provided by the contact module in the footer menu. Only links that are added using menu link content entities have a link field.
For those, just disable the default and add your own using Menu Link Content
Known problems
Please use the issue queue to search for any known issues or to add a new one.
Credits
Link attributes was written by Lee Rowlands (@larowlan).
Tutorials
- Drupal modules the one percent did a screencast of this module in action (2 minutes long)
Similar modules
Whilst these modules have a similar impact on menu links, they don't support the generic link field like Link Attributes does. Using Link attributes means you can leverage this functionality for link fields on any entity type, not just menu links.
- Menu attributes: https://www.drupal.org/project/menu_attributes
- Menu Link Attributes: https://www.drupal.org/project/menu_link_attributes
- Menu Item Extras: https://www.drupal.org/project/menu_item_extras
Ask your assistant about Link Attributes widget
Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works
Depends on
Dependencies of the latest stable release
- link Drupal core
Required by
7 tracked projects depend on this one
- Droopler 233 sites
- Seeds SEO 126 sites
- Dropsolid Rocketship Install Profile 88 sites
- Drupal Website Development 33 sites
- OpenFed 4 sites
- Link with description - Attributes 1 sites
- Webtheme Default Content
More in the Link ecosystem
Most installed first
Activity
Release Timeline
Releases
| Version | Type | Core | PHP | Release date | |
|---|---|---|---|---|---|
| 2.1.3 | Stable | 9–11 | Jun 20, 2026 | ||
| 2.1.2 | Stable | 9–11 | Nov 13, 2025 | ||
| 2.1.1 | Stable | 9–11 | PHP 8 | Jul 19, 2024 | |
| 2.1.0 | Stable | 9–10 | PHP 8 | Jul 26, 2023 | |
| 2.0.2 | Stable | 9–10 | PHP 8 | Jul 14, 2023 | |
| 2.0.1 | Stable | 9–10 | PHP 8 | Jul 11, 2023 | |
| 2.x-dev | Dev | 9–11 | PHP 8 | Jun 22, 2023 | |
| 2.0.0 | Stable | 9–10 | Jun 22, 2023 | ||
| 8.x-1.14 | Stable | 9–10 | Jun 22, 2023 | ||
| 8.x-1.13 | Stable | 9–10 | Feb 21, 2023 |