The simplest way to link to a PDF
A link to a PDF works the same way as a link to any other file on the web. You write or paste the web address of the PDF into your HTML code, and when someone clicks the link, their browser either opens the PDF or prompts them to download it—depending on their browser settings and the PDF's size.
The most common method uses an anchor tag with an href attribute. The href tells the browser where to find the file. If you are building a website or editing HTML, you write something like this:
<a href="https://example.com/documents/myfile.pdf">Click here to read the PDF</a>
The text between the opening and closing tags—"Click here to read the PDF"—is what the reader sees and clicks on. The href attribute points to the actual PDF file.
Key Takeaways
- A PDF link requires the full web address (URL) of the PDF file and an HTML anchor tag with an href attribute pointing to that address.
- The text you write between the opening and closing anchor tags is what appears as the clickable link on your page.
- If you do not have a web address for your PDF yet, you must first upload the file to a web server or cloud storage service that provides a shareable link.
- Most modern browsers open PDFs directly in the browser window, but you can force a download by adding a download attribute to your anchor tag.
- Test your link in at least two browsers to make sure it works and behaves the way you expect.
Getting the web address of your PDF
Before you can create a link, you need the actual web address—the URL—of the PDF file. If the PDF is already on a website, you can usually right-click on the PDF link, select "Copy link address" or "Copy link location," and paste that into your own link code.
If your PDF is not yet on the web, you have several options. You can upload it to your own website's file server using an FTP client or your hosting provider's file manager. You can also upload it to a cloud storage service like Google Drive, Dropbox, or OneDrive, which will generate a shareable link for you. Each service has slightly different steps, but they all produce a URL you can use in your href attribute.
Make sure the link you copy actually points to the PDF itself, not to a preview page or a folder. Test it by pasting the URL into your browser's address bar—it should either open the PDF or start a download.
Writing the HTML code for your link
If you are editing a website directly, you will work with HTML. The basic structure is always the same: an opening anchor tag with href, the visible link text, and a closing anchor tag.
Here are three real examples:
- <a href="https://example.com/files/report.pdf">Download our annual report</a>
- <a href="https://drive.google.com/uc?export=download&id=1ABC123">View the policy document</a>
- <a href="/documents/guide.pdf">Read the user guide</a>
The third example uses a relative path (starting with a slash) instead of a full web address. This works only if the PDF is stored on the same server as your website. The first two use full URLs and work from anywhere.
The link text—the part the reader clicks—should be descriptive. "Download our annual report" tells the reader what they are getting. "Click here" does not.
Making the browser download instead of opening the PDF
By default, most modern browsers open PDFs in a new tab or window. If you want the browser to download the file instead, add a download attribute to your anchor tag.
<a href="https://example.com/files/report.pdf" download>Download our annual report</a>
You can also specify what name the downloaded file should have by giving the download attribute a value:
<a href="https://example.com/files/report.pdf" download="2024-annual-report.pdf">Download our annual report</a>
This tells the browser to save the file as "2024-annual-report.pdf" instead of whatever name it had on the server. This is useful when the original filename is unclear or when you want the downloaded file to have a more readable name.
Linking to a PDF from a website builder or content management system
If you use WordPress, Wix, Squarespace, or another website builder, you usually do not write HTML directly. Instead, you use a link button or menu option in the editor.
In WordPress, highlight the text you want to turn into a link, click the link icon in the toolbar, and paste the PDF URL into the URL field. In Wix, use the "Link" option from the toolbar. In Squarespace, select text and choose "Link" from the formatting menu. Each platform then generates the HTML code for you behind the scenes.
The process is the same regardless of the platform: you provide the link text and the URL, and the builder creates the anchor tag. If you need the PDF to download instead of opening in the browser, look for a "download" or "open in new tab" option in the link settings.
Testing your PDF link
After you create a link, test it in at least two different browsers—Chrome, Firefox, Safari, or Edge. Click the link and verify that the PDF either opens or downloads as you intended. Check that the correct file appears and that the filename is readable if it was downloaded.
If the link does not work, the most common causes are a typo in the URL, a file that has been moved or deleted, or incorrect permissions on the server. Copy the URL directly from your browser's address bar and compare it character by character to the href in your code. If the URL is correct but the link still fails, check that the file still exists at that location and that the server allows public access to it.
Also test on a mobile device if your website is viewed on phones or tablets. Some mobile browsers behave differently with PDFs than desktop browsers do.
Frequently Asked Questions
What is the difference between a relative path and a full URL in a PDF link?
A relative path like /documents/guide.pdf works only if the PDF is on the same server as your website. A full URL like https://example.com/documents/guide.pdf works from anywhere and is more reliable if you are linking to a PDF on a different website or server.
Can I link to a PDF stored in Google Drive or Dropbox?
Yes. Both services generate shareable links when you right-click a file and select "Share" or "Get link." Paste that link into your href attribute. For Google Drive, you may need to adjust the link slightly to force a download instead of a preview—add &export=download to the end of the URL.
Why does my PDF link open in the browser instead of downloading?
Most browsers are set to open PDFs by default. Add the download attribute to your anchor tag to force a download. If that does not work, the issue may be with your browser settings rather than your link code.
Do I need to do anything special to link to a password-protected PDF?
No. The link itself does not change. When someone clicks the link and the PDF opens, the browser will prompt them for the password if the PDF requires one. The password protection is built into the PDF file, not the link.
What should I write as the link text?
Write something that describes what the reader will get: "Download the 2024 budget," "Read the privacy policy," or "View the technical specifications." Avoid vague text like "Click here" or "PDF." Descriptive text helps readers decide whether to click and also helps with search engine visibility.