Want to give control back to your website visitors and magically stop all links from opening in new windows or tabs without editing all your content? This article explains how to easily stop all links on your WordPress site from opening new windows or tabs.
How to Block Links From Opening New Windows or Tabs in WordPress
If your website is has many links that open in a new window or tab, it can be time-consuming to remove that setting on links one-by-one. Links that open new windows or tabs can be easily fixed using the WordPress Accessibility Checker plugin – saving your from having to manually edit your content.
Step 1
Click into the Accessibility Checker plugin settings in your WordPress dashboard (you must be logged in with an administrator account to access these settings).
Step 2
Go to the “Fixes” tab in the Settings Tabs navigation.
Step 3
Check the box for Block Links Opening New Windows, then scroll to the bottom of the page and click the “Save Changes” button.
Note: Automated accessibility fixes use JavaScript or other methods to modify how your website functions. Occasionally, a WordPress theme or extension may conflict with or prevent our fixes from working as expected. We recommend testing these fixes on a local or staging copy of your website first.
Not seeing the fix?
The Block Links Opening New Windows accessibility fix should start working immediately; however, if you don’t see the fix, it could be because you’re seeing a cached version of your website. Try clearing the cache in any caching plugins and on your hosting account, then look at your site in an incognito window to confirm the fix worked.
Note: Turning on a fix will not instantly remove related issues from Accessibility Checker reports. After turning on a fix, you can clear issues from reports by running a full site scan in Accessibility Checker Pro or by saving any individual post/page to trigger a rescan of that post/page only.
What This Fix Does
When enabled, the Block Links Opening New Windows fix finds links on your website that would open in a new tab or window and modifies the code to force them to open in the same tab instead. This fix removed target="_blank"
from links.
Once you turn it on, this fix will be applied to every link on your website. However, there are some cases in which you may want links to still open in a new window or tab (such as a link to a privacy policy in a form where you don’t want people to lose progress). Accessibility Checker provides an override for these links.
Allowing specific links to open in new tabs
To override the fix on certain links, an “exception” class can be added links or their parent containers. Accessibility Checker will detect this class and allow links in those area(s) to open in new tabs.
Here is that class:
.edac-allow-new-tab
Here is a basic code example where the exception class is added to a hyperlink that’s been configured to open in a new tab:
<a href="https://www.example.com/privacy-policy" class="edac-allow-new-tab" target="_blank">Read Privacy Policy</a>
You can add this class in the “Additional CSS class(es)” field in the WordPress block editor, in similar CSS class fields in your page builder, or by editing a link’s HTML code.
Please note that it is best to use this exception class sparingly.
Please consult with an accessibility specialist if you are not sure whether an exception should apply.
Impact on Accessibility
Opening links in new tabs or windows can disrupt the user experience, especially for screen readers or keyboard navigation users. It can be disorienting when the user is suddenly taken away from their current context without any clear indication. This can also create difficulties for users with cognitive disabilities who may struggle to manage multiple tabs or windows.
Keeping links in the same tab generally offers a smoother and more predictable browsing experience for everyone.
Associated Checks
The following checks in Accessibility Checker are associated with this fix: