How to hyperlink to a PDF

Most links to a document technically work and practically fail, because tapping one starts a download instead of showing the document.

A hyperlink to a document is one line of markup. Whether the document opens on screen or lands in a downloads folder is decided somewhere else, and that is the part worth getting right.

A document link tapped on a phone. The document renders on screen rather than downloading.
A document link tapped on a phone. The document renders on screen rather than downloading.

This guide covers the display-or-download decision, the link text that prevents a bad surprise, and what to do about new tabs.

The markup is the easy part

<a href="/docs/price-list.pdf" target="_blank" rel="noopener">
  Price list (PDF, 2MB)
</a>

Three things are doing work here.

The new-tab attribute keeps the reader on the page they were on. The noopener attribute goes with it for safety, and should be habit rather than a decision.

And the link text names the document and its size. That single detail prevents the most common complaint about document links, which is a reader on a phone connection suddenly pulling down something large without warning.

Display or download is a server decision

This is the part that surprises people.

Whether tapping a link shows the document or saves it is not chosen by the browser and cannot be chosen by the reader. The server sends a header with the file that says, in effect, show this or save this.

If your document always downloads and you want it to display, the fix is on the server, not in the markup. If you are putting the document at an address through a hosting tool, this is usually a setting on the page rather than something you configure by hand.

Which one should you pick?

Display Download
Reader wants to read it now Correct Wrong
Reader wants to keep it Extra step Correct
On a phone Opens on screen Lands in a folder
Menu, brochure, price list Display
Contract, form to print Download

For most documents, display, with a download link underneath for the people who want the file.

Linking to a page inside the document

Adding a page reference to the end of the address jumps the reader to that page.

/docs/handbook.pdf#page=14

It works in most desktop browsers and inconsistently on phones, so use it to be helpful rather than to be precise. If a reader absolutely must see page fourteen, say so in the surrounding text as well.

Link text naming the document and its size, next to a vague "click here" for comparison.
Link text naming the document and its size, next to a vague "click here" for comparison.

The reader decides whether to tap based on the text. Four words do most of the work.

Name the document. Price list, not "this file".

Say it is a document. The reader is choosing whether to leave the page.

Give the size. Anything over a couple of megabytes deserves a warning on a phone.

Skip "click here". It tells the reader nothing and reads badly aloud, which matters for anyone using a screen reader.

Closely related: How to share a PDF as a link, and How to create a URL for a PDF for the adjacent problem. Creating course materials as documents and pages is also close.

Put it at an address

Decide display or download, open it in a new tab, name the document and its size in the link text, and test it on a phone.

Then the link does what the reader expected.

Questions people ask

Why does my link download instead of opening?

Because the server is telling the browser to treat the file as an attachment rather than something to display. It is a header, not a browser setting, so the reader cannot fix it from their side.

Should the link open in a new tab?

For a document, yes. The reader is usually mid-task on the page they came from, and sending them away from it costs you the rest of the page. Use a new tab and say so in the link text.

What should the link text say?

What the document is and roughly how big it is. "Price list, PDF, 2MB" respects the reader more than "click here", and it prevents the surprise of a large file on a phone connection.

Can I link to a specific page?

Yes, by adding a page reference to the end of the address. Support varies by reader app, so treat it as a convenience rather than something to rely on for an important instruction.

Does linking to a document help search?

Search engines do read documents, but a page is easier for them and far easier for a reader on a phone. If the content matters for search, put it on a page and offer the document alongside.

Keep reading