Href open pdf in new tab
To open a PDF in a new tab when clicking on an <a>
link with an href
attribute, you can use the following syntax:
<a rel="nofollow" target="_blank" href="path/to/pdf.pdf" target="_blank">Link text</a>
The target
attribute specifies that the link should open in a new tab or window. The value _blank
tells the browser to open the link in a new tab.
For example:
<a rel="nofollow" target="_blank" href="example.pdf" target="_blank">Open PDF in new tab</a>
This will open the PDF file in a new tab when the link is clicked.
Note that you can also use target="_new"
or target="_blank"
to achieve the same result.
If you want to open the PDF in a new tab and also specify a specific width and height for the PDF viewer, you can use the following syntax:
<a rel="nofollow" target="_blank" href="path/to/pdf.pdf" target="_blank" rel="noopener noreferrer" width="800" height="600">Link text</a>
The rel
attribute specifies that the link should not be followed by the browser if the user clicks the "Back" button. The width
and height
attributes specify the width and height of the PDF viewer in pixels.
For example:
<a rel="nofollow" target="_blank" href="example.pdf" target="_blank" rel="noopener noreferrer" width="800" height="600">Open PDF in new tab</a>
This will open the PDF file in a new tab with a width of 800 pixels and a height of 600 pixels.