Reputation: 724
I am trying to make a Github pages website. I have an image of my report on my page. I want to be able to click on the image and have the PDF open up in a new tab. How would I do that?
Is this correct?
<a href="/uploads/ReportBlank.pdf"><img src="images/report_placeholder.png"/></a>
Upvotes: 0
Views: 2653
Reputation: 4659
It's simple add a image <img>
inside a anchor tag <a>
.
<a href="file.pdf">
<img class="img-fluid" alt="open pdf" src="pdf-img.png">
</a>
If you want open PDF in new tab add target="_blank"
Upvotes: 0
Reputation: 16204
There is no way to force the browser to open in a new tab but giving the link a target may work in many browsers:
<a href="/uploads/ReportBlank.pdf" target="_blank"><img src="images/report_placeholder.png"/></a>
In practice, the users' software and preferences will mostly dictate where and what opens this file.
Upvotes: 1