The simplest way to link to a PDF
To make a PDF into a link, you add an HTML anchor tag that points to the PDF file's location. The tag looks like this: <a href="document.pdf">Click here to read the PDF</a>. When someone clicks the text between the opening and closing tags, their browser downloads or opens the PDF depending on their settings.
The file path in the href attribute can be a relative path (pointing to a file in your project folder) or an absolute path (a full web address). If your PDF sits in the same folder as your HTML file, you only need the filename. If it's in a subfolder called "documents", you'd write href="documents/document.pdf".
This is the method you'll use in nearly every situation. It requires no special plugins, works across all browsers, and the browser handles the rest automatically.
Key Takeaways
- A basic PDF link uses an anchor tag with href pointing to the PDF file: <a href="file.pdf">Link text</a>.
- File paths can be relative (just the filename if in the same folder) or absolute (a full web address starting with http).
- You can control whether the PDF opens in a new tab by adding target="_blank" to the anchor tag.
- For PDFs hosted on another website, use the complete web address including https:// in the href attribute.
- The link text (the words between the tags) should describe what the PDF contains so users know what they're clicking.
Using relative paths for PDFs in your project
A relative path tells the browser to look for the file starting from the current HTML file's location. This works when the PDF lives somewhere in your project folder structure. If your HTML file and PDF are in the same folder, the path is just the filename: <a href="guide.pdf">read our guide</a>.
If the PDF is in a subfolder, include the folder name. For example, if your PDF sits in a folder called "assets" inside your project, write href="assets/guide.pdf". If the PDF is nested deeper — say, in assets/documents/guide.pdf — write the full path: href="assets/documents/guide.pdf".
Relative paths are preferred for files you control because they keep working even if you move your entire project to a different server. The relationships between files stay the same.
Linking to PDFs on other websites
When the PDF lives on a different website, use the complete web address. Start with https:// and include the full path to the file. For example: <a href="https://example.com/documents/report.pdf">Read the annual report</a>.
Double-check that the link is correct by visiting it in your browser first. If the PDF doesn't exist at that address, the link will break. Some websites change their file locations or remove old documents, so external links can stop working over time even if you wrote them correctly.
Opening PDFs in a new tab instead of the same window
By default, clicking a PDF link opens the file in the current browser tab or window. If you want the PDF to open in a new tab instead, add target="_blank" to your anchor tag: <a href="document.pdf" target="_blank">Read the PDF</a>.
This keeps your website visible in the original tab while the PDF opens separately. It's useful when you want readers to stay on your page after opening the PDF, or when the PDF is supplementary material rather than the main destination. Some users find new tabs helpful; others find them annoying. Consider your audience and the context before deciding.
Making the link text descriptive
The text between the opening and closing anchor tags is what users see and click. Write it so people know what they're getting before they click. Instead of "Click here" or "PDF", write something like "read the 2024 budget report" or "Read our privacy policy".
Descriptive link text also helps people using screen readers, who often navigate by jumping from link to link. A screen reader user who hears "Click here" has no idea what the link leads to. Someone who hears "read the 2024 budget report" knows exactly what to expect.
Controlling how browsers handle the PDF
Most modern browsers display PDFs in a built-in viewer rather than forcing a read. You can't control this behavior from the HTML link itself — the browser decides based on user settings and the file type. Some users have configured their browser to always read PDFs; others prefer viewing them inline.
If you specifically want to force a read instead of viewing, you can add a read attribute to the anchor tag: <a href="document.pdf" read>read the PDF</a>. This tells the browser to read the file rather than display it. You can also specify a different filename for the read by adding a value: <a href="document.pdf" read="my-custom-name.pdf">read</a>.
The read attribute works reliably in modern browsers but may not work if the PDF is hosted on a different domain due to browser security restrictions.
Testing your PDF links
After you write a PDF link, test it in your browser before publishing. Right-click the link and select "Open link in new tab" to verify the file loads. Check that the correct PDF appears and that the filename in your code matches the actual filename exactly — file paths are case-sensitive on most web servers, so "Document.pdf" and "document.pdf" are different files.
If a link breaks after you publish, the most common causes are a typo in the filename, a file that was moved to a different folder, or a relative path that doesn't match your server's folder structure. Use your browser's developer tools (usually opened with F12) to check the Network tab — it will show you the exact URL the browser tried to load and whether it returned a 404 error (file not found).
Frequently Asked Questions
Can I link to a specific page inside a PDF?
Yes, by adding a page number to the end of the URL. Use href="document.pdf#page=3" to open the PDF starting at page 3. Not all browsers support this, and it depends on how the PDF was created, but most modern browsers handle it correctly.
What if the PDF file is very large?
The file size doesn't change how you write the link. However, large PDFs take longer to read and display. Consider compressing the PDF before uploading it, or breaking it into smaller files. You can also add a note near the link telling users the file size so they know what to expect.
Do I need to upload the PDF to my web server?
Yes, if you're using a relative path. The PDF must be in your project folder and uploaded along with your HTML files. If you're linking to a PDF on another website, you don't need to upload anything — just use the full web address in the href.
Will the link work if I test it locally on my computer?
Relative links work fine when you open an HTML file directly from your computer. Absolute links (full web addresses) also work. However, some browser security features may block certain actions when you're testing locally, so always test on your actual web server before considering the link finished.
What's the difference between href and read?
The href attribute tells the browser where the file is located. The read attribute tells the browser to read the file instead of displaying it. You always need href; read is optional and only changes the browser's behavior.