The ability to open a link in a new tab/window is native functionality of many browsers. If you do not wish to allow this type of activity, then you need to notify the browser that your link is not truly a link. The easiest way to do so is to remove the href attribute from your a element.

HTML:

<a href="http://google.com">Can be opened in new tab/window</a>
<a>Cannot be opened in new tab/window</a>

Now there are some other things that the browser may be doing for you by default when it sees a link. If you have not defined any styling of a elements, it's likely that your new fancy pseudo-link will not appear with a link font-color, pointer, and underline. You can go ahead and do that easily enough.

CSS:

a {
    color: blue;
    cursor: pointer;
    text-decoration: underline;
}

That hopefully answers the question of how you disable/remove the 'Open Link in New Tab' option in the right-click menu of the browser. For some extra credit though I'm going to assume that you probably want the link to still function like a regular link when clicked. Feel free to use some JavaScript to make that happen. Here's an example using jQuery:

JavaScript:

$("body").on("click", "a[data-href]", function() {
    var href = $(this).data("href");
    if (href) {
        location.href = href;
    }
});

Modified Html:

<a href="http://google.com">Can be opened in new tab/window</a>
<a data-href="http://google.com">Cannot be opened in new tab/window</a>

Modified CSS:

a[href], a[data-href] {
    color: blue;
    cursor: pointer;
    text-decoration: underline;
}

Hope this helps!

Answer from Phil Klein on Stack Overflow
🌐
Builder.io
forum.builder.io › general
How do I make link within text not open a new tab? - General - Builder.io Forum
March 9, 2022 - Each of the underlined words hyperlinks out to a different url. Right now, when clicked they open up a new tab. How do I get these individual links within the same text box to keep you on the same page?
Top answer
1 of 4
15

The ability to open a link in a new tab/window is native functionality of many browsers. If you do not wish to allow this type of activity, then you need to notify the browser that your link is not truly a link. The easiest way to do so is to remove the href attribute from your a element.

HTML:

<a href="http://google.com">Can be opened in new tab/window</a>
<a>Cannot be opened in new tab/window</a>

Now there are some other things that the browser may be doing for you by default when it sees a link. If you have not defined any styling of a elements, it's likely that your new fancy pseudo-link will not appear with a link font-color, pointer, and underline. You can go ahead and do that easily enough.

CSS:

a {
    color: blue;
    cursor: pointer;
    text-decoration: underline;
}

That hopefully answers the question of how you disable/remove the 'Open Link in New Tab' option in the right-click menu of the browser. For some extra credit though I'm going to assume that you probably want the link to still function like a regular link when clicked. Feel free to use some JavaScript to make that happen. Here's an example using jQuery:

JavaScript:

$("body").on("click", "a[data-href]", function() {
    var href = $(this).data("href");
    if (href) {
        location.href = href;
    }
});

Modified Html:

<a href="http://google.com">Can be opened in new tab/window</a>
<a data-href="http://google.com">Cannot be opened in new tab/window</a>

Modified CSS:

a[href], a[data-href] {
    color: blue;
    cursor: pointer;
    text-decoration: underline;
}

Hope this helps!

2 of 4
2

2019

I'll highlight 2 important comments:

  1. nnnnnn @ Aug 10 '11 at 5:49 :

    As a user I would prefer that type of feature be triggered from a button rather than a link. I expect links to work in a more standard way including giving me the option to right-click for the menu or to middle-click to open directly in a new tab.

  2. Pars @ Dec 21 '13 at 13:10 :

    this wont work when you click by mouse middle button or hold CTRL and click on a link. how to those cases.

It's up to the browser to decide whether it gets the link-behavior or not.

Some modern browser (like Chrome) will consider it a link if all the below conditions matches:

  1. It's an <a>...</a> tag (not span, div, button, etc).
  2. It has href attribute.
  3. href attribute is not empty.

The below will get the link-behavior:

<a href="http://www.website.com">Click Here</a>

The below will NOT get the link-behavior:

<a>Not link because no href</a>
<a href="">Not link because empty href</a>
<span>Not link because not "a" tag</span>
<span href="http://www.website.com">Not link because not "a" tag again</span>

Important Note:

Again, it's up to the browser to decide. Some old/stupid browsers may give it link-behavior if ANY of the 3 conditions above matches!

Conclusion

If it's a link then use <a href="some_link">...</a>. If it's not a link then use something else, like <button>.

🌐
Google Support
support.google.com › chrome › thread › 256782217 › when-i-hit-a-link-on-a-page-it-opens-a-new-tab-how-do-i-get-that-to-go-away
When I hit a link on a page, it opens a new tab. How do I get that to go away? - Google Chrome Community
Skip to main content · Google Chrome Help · Sign in · Google Help · Help Center · Community · Google Chrome · Terms of Service · Submit feedback · Send feedback on
🌐
Equalize Digital
equalizedigital.com › home › link opens new window or tab
Link Opens New Window or Tab
August 28, 2025 - If links do open new tabs or windows, there must be a warning announcing that the link will open a new window or tab so that users will expect that behavior and know how to go back after clicking the link. The Accessibility Checker warning is intended to remind you to either change your links to not open new tabs or to ensure that a visible and auditory warning is present for any links that do open new tabs.
🌐
Duncan Mackenzie
duncanmackenzie.net › blog › do-not-open-new-tabs
Don't code links to open in a new tab or window. :: Duncan Mackenzie
May 30, 2024 - When you make a link on a web page, it is possible to provide an attribute (target) that tells the browser to open that link into a new tab or window. This is not the default. The default behavior is to stay in the same context (tab) that you are already in. With the default experience, the user has the option to right-click (or long press on a mobile device) on the link and decide if they’d like to open it in a new tab.
🌐
Google Support
support.google.com › chrome › thread › 3520860 › how-do-i-set-chrome-to-open-links-in-a-new-tab-on-the-same-browser-window
how do i set chrome to open links in a new tab on the same browser window? - Google Chrome Community
Skip to main content · Google Chrome Help · Sign in · Google Help · Help Center · Community · Google Chrome · Terms of Service · Submit feedback · Send feedback on
🌐
Glide Community
community.glideapps.com › ask for help
How to make a link that don't open a new page in the browser - Ask for Help - Glide Community
April 25, 2020 - Hi, I am a link that don’t open a new browser page but replace the existing one. Is this possible in glide?
🌐
Quora
quora.com › How-do-I-prevent-websites-from-opening-in-a-new-tab-when-I-left-click-on-a-link-and-instead-it-opens-in-the-current-tab
How to prevent websites from opening in a new tab when I left click on a link and instead it opens in the current tab - Quora
Answer (1 of 2): There is not a way that I know of to prevent a link from opening in a new tab if it has been programmed specifically to do that. You can look into the source code of a website and see which links will open in a new window based on their target attribute. [code]
Find elsewhere
🌐
Microsoft Power Platform Community
powerusers.microsoft.com › t5 › Building-Power-Apps › Prevent-HTML-links-from-opening-a-new-tab › td-p › 326263
Forums | Microsoft Power Platform Community
Microsoft Power Up Program enables non-tech professionals to successfully advance into a new career path in low-code application development using Microsoft Power Platform.
🌐
W3Schools
w3schools.com › tags › tryit.asp
The a target attribute
The W3Schools online code editor allows you to edit code and view the result in your browser
🌐
Web Communication
web.wsu.edu › web-training › resources › accessibility-resources › open-in-new-tab
Open in New Tab | Web Communication | Washington State University
This code is different from the one used on Checking Links. Use this code if you want links to open in new a tab and check for noreferrer noopener. Use Checking Links: Open in a New Tab if you do not want links to open in a new tab.
🌐
Mozilla Support
support.mozilla.org › en-US › questions › 1319496
How to prevent every link I click to open in a new tab | Firefox Support Forum | Mozilla Support
Hey Fred, Thanks so much for the guidance. Unfortunately, I have been to this area, and the only options they offer are to open links in new window or when opening them in new tab, switch directly to them. The other two items under Tabs do not alter or adjust the process.
🌐
The Admin Bar
theadminbar.com › accessibility-weekly › opening-links-in-new-tabs-or-not
Best Practices: Opening Links for Accessibility
October 5, 2024 - Learn why using target='_blank' for links can hinder accessibility and discover best practices for improving user experience.
🌐
Google Support
support.google.com › websearch › thread › 57784986 › google-chrome-opening-new-tab-every-time-i-click-a-link
Google Chrome Opening New Tab Every Time I Click A Link? - Google Search Community
Skip to main content · Google Search Help · Sign in · Google Help · Help Center · Community · Google Search · Terms of Service · Submit feedback · Send feedback on
🌐
W3C
w3.org › WAI › WCAG21 › Techniques › general › G200
G200: Opening new windows and tabs from a link only when necessary | WAI | W3C
The objective of this technique is to limit the use of links or buttons that open new windows or tabs within web content. In general, it is better not to open new windows and tabs since they can be disorienting for people, especially people who have difficulty perceiving visual content.
🌐
Western Washington University
marcom.wwu.edu › accessibility › guide › links-should-open-same-tabwindow
Links should open in the same tab/window | University Communications and Marketing | Western Washington University
Most links should not open in a new tab or window by default using the target="_blank" attribute. By keeping the default link behavior, users can then decide for themselves whether to open the page in a new tab or window.