I am probably missing something simple here, however i will ask anyway. I have made a link to open up a PDF file, however it opens up in the current tab rather than a new one. What code shall i use in HTML to open a new tab to read the PDF file.
42.6k 16 16 gold badges 121 121 silver badges 164 164 bronze badges asked Jun 4, 2013 at 19:00 MultiWizard MultiWizard 729 2 2 gold badges 6 6 silver badges 5 5 bronze badges Does this answer your question? How to open link in a new tab in HTML? Commented Dec 15, 2022 at 16:54Target _blank will force the browser to open it in a new tab or window (depending on user browser settings).
answered Jun 4, 2013 at 19:02 3,785 24 24 silver badges 30 30 bronze badgesNope. If the user has set their browser to do something different with PDF files (like download them) it won't open in a new tab. There's no way to guarantee a PDF to open in a new browser window.
Commented Jun 12, 2016 at 21:33 @ChuckLeButt Where did I state that this is guaranteed to open the page in a new window? Commented Feb 1, 2017 at 11:38Quote: Target _blank will force the browser to open it in a new window . That's simply not true. You cannot force a browser to open a PDF. It may simply be downloaded, depending on the user's settings, even with the target attribute set to "_blank". See my answer below.
Commented Feb 1, 2017 at 15:49 Force != guaranteed :) Commented Jan 18, 2019 at 16:21 There is no way to force a browser to open a PDF in a new window. Commented Jan 20, 2019 at 12:18As everyone else has pointed out, this can work:
But what nobody has pointed out is that it's not guaranteed to work.
There is no way to force a user's browser to open a PDF file in a new tab. Depending on the user's browser settings, even with target="_blank" the browser may react the following ways:
Take a look at Firefox's settings, for example:

Chrome has a similar setting:

If the user has chosen to "Save File" in their browsers settings when encountering a PDF, there is no way you can override it.
answered Jun 12, 2016 at 21:32 Chuck Le Butt Chuck Le Butt 48.4k 62 62 gold badges 208 208 silver badges 296 296 bronze badges at least can we detect that and use fallback? Commented Dec 9, 2018 at 2:10@ParthibanRajendran No. You cannot detect the user's settings, but even if there was, you could still not override their settings.
Commented Jan 18, 2019 at 14:57An observation, _blank alone will not make sure the file is opened in a new tab. The response header for the file request should have Content-Type : application/pdf .
Try this link, it will open the file in new tab as the server provide required headers.
Same is the case for other file types also. For ex: video files get request should have proper Content-Type like video/mp4 .
answered Jul 6, 2021 at 10:45 JEWEL JACOB JEWEL JACOB 574 6 6 silver badges 9 9 bronze badgesThis helped me, I had response header coming as Content-Type: application/octet-stream which was downloading the pdf automatically that I didn’t want. Content-Type : application/pdf is what I needed it to be.
Commented Nov 23, 2021 at 7:43"Try this link, it will open the file in new tab". Not for me in FireFox. It's still opening in the same tab.
Commented Jan 12, 2022 at 14:39 This 'link' does not open in a tab for me; how do you apply the Content-Type to this HTML content? Commented Jan 24, 2022 at 17:24Every file served by a server will have a Content-Type header. It will be either manually set as per need or derived form file type. And link not opening in new tab in all browsers, I assume there's browser specific settings for file types. In chrome desktop it actually opens in a new tab.
Commented Jan 26, 2022 at 8:33You have to use target attribute
answered Jun 4, 2013 at 19:02 4,212 1 1 gold badge 20 20 silver badges 30 30 bronze badgesJust use target on your tag
The target attribute specifies where to open the link. Using "_blank" will make your browser to open a new window/tab.
42.6k 16 16 gold badges 121 121 silver badges 164 164 bronze badges answered Jun 4, 2013 at 19:03 Diogo Moreira Diogo Moreira 1,072 2 2 gold badges 9 9 silver badges 25 25 bronze badgesYou can find more about the target attribute here.
answered Jun 4, 2013 at 19:02 48.1k 8 8 gold badges 107 107 silver badges 119 119 bronze badgesOn Chrome this has proven to work well for me.
answered Aug 8, 2019 at 11:59 Fastersixth Fastersixth 123 1 1 gold badge 2 2 silver badges 13 13 bronze badgesYes, someone has already mentioned that we can force the browser to open pdf file in new tab by using target , but depending on user's browser setting it may force to download instead of opening and I see most of the browser's settings are like so in default.
The easiest way I found is, using Google Drive. We can upload the document in drive and change the setting that anyone with the link can view the doc. Use that link like below:
When we click the link, the doc will open in the new tab from drive.
answered Sep 2, 2023 at 3:09 19 2 2 bronze badgesTry this, it worked for me.
answered May 19, 2016 at 11:36 Nishanth K Kumar Nishanth K KumarMore information is needed to understand what this does and why it might work. Please consider explaining your answer.
Commented Dec 15, 2022 at 16:52Highly active question. Earn 10 reputation (not counting the association bonus) in order to answer this question. The reputation requirement helps protect this question from spam and non-answer activity.