To embed a PDF in HTML, point an object tag at the file, with a download link inside it and another below it. The browser's built-in PDF viewer shows the document on the page; the inner link appears when the browser can't display it, and the outer one covers a viewer that loads but fails. For a PDF reader on a web page that doesn't depend on the browser's own viewer, which matters most on phones, host Mozilla's free PDF.js viewer on the same site as the file.
<object data="/files/report.pdf" type="application/pdf" width="100%" height="600">
<p>This browser can't show the PDF here. <a href="/files/report.pdf">Download the PDF</a>.</p>
</object>
<p><a href="/files/report.pdf">Open the PDF</a></p>
For a long time, putting a PDF on a page meant the Adobe Reader plugin and a fair amount of hope; the <embed> tag is a leftover from that plugin era. Every major desktop browser now ships its own PDF viewer (Firefox's is PDF.js, the same library you can host yourself), so the job comes down to two choices: which tag, and where the file lives. Here are five ways, starting with the simplest, which covers most cases.
5 Ways to Embed a PDF in HTML, Compared
All five options are plain HTML5 or JavaScript; there's no dedicated <pdf> tag. Checked November 2026 against MDN, the PDF.js docs and Adobe's developer docs.
| Method | Fallback if the PDF can't show | Relies on the browser's viewer | Setup | Where the PDF can live |
|---|---|---|---|---|
<object> | Yes, the content inside the tag | Yes | One tag | Any URL that allows framing |
<iframe> | No, put a link next to it | Yes | One tag, can lazy-load | Any URL that allows framing |
<embed> | No | Yes | One tag | Any URL that allows framing |
| PDF.js viewer | Its own error message | No, it renders with JavaScript | Host a folder of files, about 12 MB without source maps | Same site as the viewer |
| Adobe PDF Embed API | No, put a link next to it | No, Adobe's script renders it | Free client ID tied to your domain | Same site, or a host that sends CORS headers |
Embed Using the Object Tag
The <object> tag displays the PDF with the browser's built-in viewer, and anything you put between the tags becomes fallback content. MDN's advice, as of November 2026, is to put a link inside the element and another outside it, because a viewer can load and still fail to display the file, and then the inner fallback never shows.
<object
data="path/to/your/file.pdf"
type="application/pdf"
width="100%"
height="600"
title="Annual report (PDF)">
<p>Unable to display PDF. <a href="path/to/your/file.pdf">Download PDF</a> instead.</p>
</object>
<p><a href="path/to/your/file.pdf">Open the PDF in a new tab</a></p>
The type="application/pdf" attribute tells the browser what it's getting before it downloads anything, so it can go straight to the fallback if it has no viewer.
Object Tag Embed Example
Embed Using the iFrame Method
An <iframe> also uses the browser's built-in viewer, and it brings one thing <object> and <embed> don't have: loading="lazy", which holds off fetching the PDF until the reader scrolls near it. That makes it the one to use for a large PDF far down a long page; MDN notes the deferral only happens with JavaScript enabled. What it doesn't have is fallback content. Its permitted content is "none", so a "Download PDF" paragraph between the tags is never shown, though older tutorials put it there anyway. The link goes outside.
<iframe
src="path/to/your/file.pdf"
width="100%"
height="600"
loading="lazy"
title="Annual report (PDF)"></iframe>
<p><a href="path/to/your/file.pdf">Download the PDF</a> if it doesn't show above.</p>
Add a title, so screen reader users know what the frame holds without stepping inside it. And leave sandbox off: MDN notes it can stop the built-in PDF viewer from loading at all, and the viewer already sandboxes the PDF's own scripts.
Older tutorials also wrap the file in Google's viewer, docs.google.com/viewer?url=...&embedded=true. Google doesn't document that URL today, and reports of it failing go back years, so we wouldn't build a page on it; PDF.js, below, does the same job on your own site.
iFrame Method PDF Embed Example
Download PDF if it doesn't show above.
Embed Using the Embed Tag
The shortest of the three is <embed>, a void element with no closing tag:
<embed src="path/to/your/file.pdf" type="application/pdf" width="100%" height="600">
It still works, since <embed> can show anything the browser handles itself. But MDN points PDF previews at <object> or <iframe> instead: <embed> can't hold fallback content or lazy-load. It's fine for an internal page where you know the browsers; for a public page, the other two do the same thing with a safety net.
Embed a PDF Viewer on a Web Page With PDF.js
If you want a PDF reader embedded in the web page, with a toolbar, search and zoom that behave the same in every browser, PDF.js is the usual answer. Mozilla's open-source library, the engine behind Firefox's viewer, draws the pages with JavaScript, so the browser doesn't need a PDF viewer of its own.
The current release is 6.5.438, published November 1, 2026. Its prebuilt download (pdfjs-6.5.438-dist.zip, 6.5 MB) unpacks into a build/ folder with the library and a web/ folder with the full viewer, about 22 MB across 536 files. Roughly 10 MB of that is .map source-map files, and another 1 MB is a sample PDF (web/compressed.tracemonkey-pldi-09.pdf) you won't need once you pass your own file; both can stay out of the upload.
- Unzip the download into a
pdfjs/folder on your site. - Put your PDF on the same site, say
/files/report.pdf. - Point an iframe at the viewer, with the PDF's path in the
fileparameter, URL-encoded:
<iframe
src="/pdfjs/web/viewer.html?file=%2Ffiles%2Freport.pdf"
width="100%"
height="700"
loading="lazy"
title="Annual report (PDF)">
</iframe>
The same-site part isn't optional: if the file's origin doesn't match the viewer's, the stock viewer stops with "file origin does not match viewer's". It also won't run from a file:// path on your laptop, because the worker needs a web server. And Mozilla asks sites that embed the viewer to re-skin it rather than ship it unmodified, so plan on at least restyling it in web/viewer.css.
To draw the pages yourself, the library in build/ renders a page to a <canvas> in a couple dozen lines (see Mozilla's hello-world example), though paging, search and text selection are then yours to build, which is why most people start with the viewer.
Embed Using Adobe PDF Embed API
Adobe's PDF Embed API is the hosted option: Adobe's script draws the viewer, with a client ID from Adobe's developer site. It's free to use as of November 2026, and it reports reading events (document opened, page views, downloads, text copied) to a callback in your own JavaScript, or straight into Adobe Analytics if your organization already subscribes to it. The script is served from acrobatservices.adobe.com:
<div id="adobe-dc-view" style="height: 600px;"></div>
<script src="https://acrobatservices.adobe.com/view-sdk/viewer.js"></script>
<script>
document.addEventListener("adobe_dc_view_sdk.ready", function () {
var adobeDCView = new AdobeDC.View({clientId: "YOUR_CLIENT_ID", divId: "adobe-dc-view"});
adobeDCView.previewFile({
content: {location: {url: "https://example.com/files/report.pdf"}},
metaData: {fileName: "report.pdf"}
}, {embedMode: "SIZED_CONTAINER"});
});
</script>
The client ID is registered to one domain; per Adobe's getting-started guide, the script checks it once the first page renders and blocks the preview anywhere else. The script also downloads the PDF itself, so Adobe's how-to guide says to keep the page and the PDF on the same domain or turn on CORS headers for the PDF. The PDF Embed API docs show a live demo of each embed mode: FULL_WINDOW (the default), SIZED_CONTAINER, IN_LINE and LIGHT_BOX. The trade-off is the usual one with a hosted script: your page now depends on Adobe's servers and Adobe's terms, and the script URL has already moved once.
Do Embedded PDFs Work on Phones?
Not reliably, so keep a visible link next to every embed and use PDF.js where the embed matters. navigator.pdfViewerEnabled tells you part of the story: it returns true when the browser can show a PDF inline on navigation, and when it can't, MDN says the PDF is downloaded instead. It's supported in Chrome 94, Firefox 99 and Safari 16.4 and up, mobile versions included, as of November 2026.
if (!navigator.pdfViewerEnabled) {
// No inline viewer: swap the embed for a plain link, or load PDF.js
}
Two caveats. The property answers "will opening the PDF show it", which isn't quite the same as "will it render inside your iframe". And Firefox returns true even when the user has set PDFs to open in another app.
Chrome on Android now opens a tapped PDF link inside the browser on Android 12 and up, according to Google's Chrome help (November 2026), but that page covers links, not PDFs framed inside another page. Apple's developer docs don't say how Safari on iPhone shows a framed PDF either, and threads on Apple's developer forums (2020 to 2023) report embeds that show only the first page. So we'd treat a native embed on a phone as a bonus and test on a real handset.
Making Your PDFs Responsive
The old trick here was a padding-top percentage on a wrapper, usually set to 16:9, which suits video and squashes a portrait document. CSS aspect-ratio does the job on the element itself:
.pdf-embed {
width: 100%;
aspect-ratio: 8.5 / 11; /* US Letter, portrait; use 210 / 297 for A4 */
max-height: 90vh;
border: 0;
}
Add class="pdf-embed" to the <object> or <iframe> and drop the fixed height. The max-height stops a tall page from swallowing the whole screen on a desktop monitor.
Control the Viewer With PDF Open Parameters
Both features below are PDF open parameters, a convention that goes back to Adobe Acrobat: you add them after a # at the end of the PDF's URL. Browser viewers support some of them, and none promise all.
Custom Controls
Hide the viewer's toolbar:
<object
data="document.pdf#toolbar=0&navpanes=0"
type="application/pdf"
width="100%"
height="600">
</object>
Chrome hides the toolbar for toolbar=0, unless navpanes=1 is also set, which brings it back (that's how Chrome's PDF viewer code reads the parameters). Firefox's viewer documents page, zoom, nameddest and pagemode, and toolbar isn't on that list, so expect the toolbar to stay there. Hiding the toolbar removes the download button; it doesn't protect the file, since anyone can open the PDF's URL directly.
Page-Specific Display
Direct users to specific pages in your PDF:
<object
data="document.pdf#page=5&zoom=auto"
type="application/pdf"
width="100%"
height="600">
</object>
page and zoom are the most widely honored parameters. In the PDF.js viewer, they go after the viewer URL instead: viewer.html?file=%2Ffiles%2Freport.pdf#page=5&zoom=page-width.
Where the PDF Should Live
Put the PDF on the same site as the page: it's the one setup that works for all five. The three tags frame the PDF, so its URL has to allow framing. PDF.js and Adobe's viewer fetch the file with JavaScript instead: Adobe's needs the same site or CORS headers, and the stock PDF.js viewer takes only a file from its own site. If the file isn't online yet, our PDF hosting guide compares the options, and if you only need to send it to someone, here's how to make a PDF a link.
On a different host, these decide whether the embed works:
X-Frame-Options:DENYblocks every frame, andSAMEORIGINblocks frames on other sites, for<iframe>,<object>and<embed>alike.Content-Security-Policy: frame-ancestorsdoes the same job with more options. Either way it's the host's call, so a PDF that opens fine in its own tab can stay blank in a frame on another site.Content-Disposition: attachmenttells the browser to download the file, so the frame stays empty.Content-Typeshould beapplication/pdf; a generic download type gets the same result.- HTTPS: an HTTPS page won't load a PDF from a plain
http://URL, since browsers block it as mixed content.
To tell which one it is, open the PDF's URL in its own tab. If it downloads there too, it's Content-Disposition or Content-Type. If it opens on its own but stays blank in the frame, look for X-Frame-Options or frame-ancestors in the Network tab of your browser's developer tools. On a phone, a download usually just means there's no inline viewer, which is what the link is for.
A Drive or Dropbox share link opens the service's own viewer page, which won't load in data or src. Drive can generate embed code instead, an iframe on the file's /preview address, but that puts Drive's viewer, Drive's toolbar and Drive's sharing rules on your page: the file has to be viewable by anyone with the link.
On Hostsmith, the dashboard takes one file at a time, a ZIP or a single file such as a PDF. To keep the page and the PDF together, drop your zipped folder with index.html and a files/ folder holding the PDF, and both go live at the same address, for example your-site.us.hostsmith.link/files/report.pdf. A new upload replaces all of the site's files at the same address, so keep the PDF's filename and the embed keeps pointing at it.
Storage is the limit to check first, as of November 2026:
| Plan | Price | Storage | Custom domain |
|---|---|---|---|
| Free | $0 | 5 MB, also the largest single upload | No |
| Starter | $5/mo billed yearly, $9 monthly | 50 MB | No |
| Pro | $15/mo billed yearly, $21 monthly | 500 MB | Yes, up to 5 |
Agency (10 GB) and Premium (1 TB) add more sites and domains; see pricing. A single brochure fits the Free plan, which also shows the Hostsmith watermark (paid plans don't). The full PDF.js viewer is around 12 MB without its source maps, more than Free's 5 MB of storage, so a site that carries it takes Starter (50 MB) or up. If the document isn't for everyone, Private Sites (Starter and up) puts a shared password or an email whitelist in front of the whole site, page and PDF together. And if it gets printed too, a QR code for the PDF sends readers from paper to the same file.
Frequently Asked Questions
Q: How do I embed a PDF on a web page?
A: Upload the PDF to the same site as the page, then add an object tag with data set to the PDF's path, type="application/pdf", a width and a height, and a download link inside it. Add a second link below the embed for browsers whose viewer loads but fails.
Q: How do I embed a PDF reader in a web page?
A: Host Mozilla's PDF.js viewer on your site and load it in an iframe with the PDF's path in the file parameter, for example /pdfjs/web/viewer.html?file=%2Ffiles%2Freport.pdf. Its toolbar, search and zoom don't depend on the browser's own viewer. Adobe's free PDF Embed API is the hosted alternative.
Q: What is the HTML5 way to embed a PDF?
A: HTML5 has no dedicated PDF tag. The object, iframe and embed elements all display PDFs through the browser's built-in viewer. Object is the only one with fallback content, and iframe is the only one that can lazy-load.
Q: Why does my embedded PDF download instead of showing?
A: Usually one of three things. The host sends Content-Disposition attachment, the host sends the wrong Content-Type, or the browser has no inline PDF viewer, which is still common on phones. Open the PDF URL in its own tab to tell which.
Q: Can I stop people downloading an embedded PDF?
A: Not really. Adding toolbar=0 after a hash at the end of the PDF URL hides the download button in Chrome, but the file is still at its URL, and anyone can open that directly. If only some people should see the document, put it behind a password instead.
Q: Will embedding PDFs affect my page load time?
A: Yes, a large PDF is a large download. Compress the file, lazy-load it with an iframe if it sits below the fold, and link a long document instead of embedding it when most readers only need the first page.
Start With Object, Add PDF.js When Phones Matter
To embed a PDF in HTML on most pages, start with <object> and a link inside it, put a second link underneath, and stop there unless you have a reason not to; it's the boring option, and it'll still work long after the next viewer API has been renamed. When phone readers matter or you want one viewer everywhere, host PDF.js next to the file. And whichever you pick, keep the PDF on the same site as the page, which avoids most of what can go wrong.
Got the page and the PDF in one folder? Zip it and drop it at hostsmith.net, and both will be live at one address, embed included.