Five easy ways to embed and display a PDF in HTML (no JavaScript needed)

This article will explore various methods for embedding PDF files in HTML, including using the object tag, iframe tag, and embed tag. Each method has its own set of advantages and disadvantages, which will be discussed in detail. Additionally, this article will provide best practices for embedding PDFs to ensure they’re displayed correctly and provide a seamless user experience.
Five easy ways to embed and display a PDF in HTML (no JavaScript needed)
TL;DR

Need to display a PDF in HTML without extra libraries? Use one of these native options: <object>, <iframe>, <embed>, or a combo of <object> + <iframe> for maximum fallback support. They’re quick to implement but come with tradeoffs like limited customization and uneven browser behavior. For annotations, forms, digital signatures, or a brand‑consistent user interface (UI), switch to a dedicated JavaScript PDF viewer — we recommend Nutrient Web SDK.

Embedding a PDF in HTML keeps viewers on your page, preserves document layout across devices, and boosts engagement — all without JavaScript or plug‑ins. This post will walk through five methods, complete with copy‑and‑paste code examples and optimization tips.

If you prefer video, watch the tutorial below.

Method 1 — Display a PDF in HTML with the object tag

The HTML <object> element taps the browser’s built‑in PDF reader and lets you add a plain text fallback:

<object
data="https://example.com/test.pdf#page=2"
type="application/pdf"
width="100%"
height="100%"
>
<p>
Your browser does not support PDFs.
[Download the PDF](https://example.com/test.pdf)
.
</p>
</object>

Pros

  • No JavaScript or external viewer required.
  • Allows a graceful fallback message.

Cons

  • Styling is locked to the browser’s PDF plugin.
  • Some older browsers ignore PDF parameters like #page=2.

Method 2 — Use an iframe as a PDF viewer

Combine <object> with <iframe> to reach more browsers. The <iframe> acts as a backup when <object> fails:

<object
data="https://example.com/test.pdf#page=2"
type="application/pdf"
width="100%"
height="100%"
>
<iframe
src="https://example.com/test.pdf#page=2"
width="100%"
height="100%"
style="border: none;"
>
<p>
Your browser does not support PDFs.
[Download the PDF](https://example.com/test.pdf)
.
</p>
</iframe>
</object>

Pros

  • Broad support across modern browsers and mobile devices.
  • Works inside <object> fallback for extra reach.
  • Easy to size and style the surrounding container with CSS.

Cons

  • Browser UI varies and can’t be themed.
  • Parameters like #page=2 or #toolbar=0 aren’t honored everywhere.
  • No offline fallback message unless wrapped in <object>.

Method 3 — Embed a PDF with the embed tag

The <embed> element is another effective way to display a PDF in HTML. It’s easy to implement and is widely supported:

<embed
src="https://example.com/test.pdf"
type="application/pdf"
width="100%"
height="500px"
/>

Pros

  • Shortest markup of all native options.
  • Supported by most evergreen browsers.

Cons

  • No graceful fallback content; nothing renders if the browser lacks PDF support.
  • Viewer UI is uncontrolled and inconsistent.
  • Some mobile browsers download the PDF instead of displaying it.

Method 4 — Combine object + iframe for full fallback coverage

To ensure maximum compatibility, combine the <object> and <iframe> methods. This provides a fallback option for browsers that don’t support one of the elements:

<object
data="https://example.com/test.pdf#page=2"
type="application/pdf"
width="100%"
height="100%"
>
<iframe
src="https://example.com/test.pdf#page=2"
width="100%"
height="100%"
style="border: none;"
>
<p>
Your browser does not support PDFs.
[Download the PDF](https://example.com/test.pdf)
.
</p>
</iframe>
</object>

Pros

  • Highest compatibility without JavaScript.
  • Provides a user‑friendly fallback message.

Cons

  • More verbose HTML.
  • Still inherits the limitations of each native viewer (no theming, limited API).
  • Some browsers may request the PDF twice, increasing bandwidth.

Method 5 — Upgrade to a JavaScript PDF viewer for pro features

Need annotations, form filling, search, or redaction? Swap the native tags for a full‑featured library such as Nutrient Web SDK. These viewers give you:

  • Consistent rendering across browsers.
  • Custom UI themes.
  • Extensive APIs (e.g. zoom, rotate, redact, sign).
  • Accessibility hooks (ARIA roles, keyboard navigation).

Pros

  • Feature‑rich toolkit and customizable UI.
  • Predictable, consistent rendering on every device.
  • Extensive APIs for integrations and automation.

Cons

  • Adds kilobytes (or megabytes) to your JS bundle.
  • Requires integration effort and potential licensing costs.

Problems with this approach

While native HTML tags are quick and code‑free, they come with notable downsides:

LimitationWhy it matters
Lack of customizationThe browser’s built‑in PDF viewer UI can’t be styled, themed, or extended.
Inconsistent browser supportOlder or niche browsers (e.g. legacy Internet Explorer) may require plug‑ins like Adobe Reader — or fail to render the PDF at all.
Limited API parametersOnly a handful of URL fragments (e.g. #page=2) are understood, and support is inconsistent — Safari often ignores them.

If you’re looking for a complete reference of parameters, check out the Parameters for Opening PDF Files(opens in a new tab) specification published by Adobe in 2007.

Best practices for embedding PDFs

When embedding PDF files in HTML, following best practices is crucial to ensure your PDFs are displayed correctly and provide a good user experience. Here are some tips to keep in mind:

  • Use the correct MIME type — Always specify the correct MIME type (application/pdf) when embedding a PDF file. This ensures the browser can render the file correctly.

  • Use a consistent layout — Maintain a consistent layout for your PDFs to ensure they’re displayed correctly across different browsers and devices.

  • Optimize for mobile — Ensure your PDFs are optimized for mobile devices by using a responsive design and keeping the file size manageable.

  • Provide alternative text — Include alternative text for your PDFs to make the content accessible to users with disabilities.

  • Test for compatibility — Test your PDFs for compatibility with different browsers and devices to ensure they’re displayed correctly.

By following these best practices, you can ensure your embedded PDF files provide a smooth and accessible experience for all users.

Conclusion

With the <object> or <iframe> HTML5 elements, it’s possible to show a PDF in your web app with ease. This is supported in most browsers and requires no JavaScript at all, making it a perfect approach for adding PDF support if no advanced features are necessary.

However, for use cases that require support for every browser, customization, or some of the more advanced PDF features — such as PDF annotations, interactive PDF forms, digital signatures, and more — we recommend you look into commercial alternatives.

At Nutrient, we offer a commercial, feature-rich, and completely customizable HTML5 PDF viewer library that’s easy to integrate and comes with well-documented APIs to handle complex use cases. Try out our PDF library using our free trial, and check out our demos to see what’s possible.

FAQ

How do I embed a PDF in HTML without JavaScript?

Use the native object, iframe, or embed tag with type="application/pdf". Copy the code snippets above and replace the src or data URL with your file.

Which HTML tag offers the best browser support?

A combo of object (primary) and an iframe fallback covers virtually every modern desktop and mobile browser, including Safari on iOS and Chrome on Android.

Can I open a PDF on a specific page or zoom level?

Append URL fragments like #page=2, #zoom=100, or #toolbar=0 to the PDF URL. Support varies by browser—Chrome and Edge usually honor them, while Safari may ignore some parameters.

How can I hide the download button or toolbar?

Native viewers don’t offer reliable UI control. For consistent branding or to hide the UI, switch to a JavaScript viewer such as Nutrient Web SDK or PDF.js.

What’s the best way to make embedded PDFs responsive on mobile?

Wrap the viewer in a container div with width: 100% and a flexible height set via CSS or viewport units. Then allow overflow scrolling or pinch‑to‑zoom as needed.

What happens if the browser can’t display PDFs?

Provide a fallback paragraph inside the object or iframe element with a direct download link, so users can still access the document.

How large should my PDF be?

Aim for under 5 MB for quick loads on mobile networks. Compress images, subset fonts, and remove unused metadata to shrink the file size.

Philipp Spiess

Philipp Spiess

Hulya Masharipov

Hulya Masharipov

Technical Writer

Hulya is a frontend web developer and technical writer at Nutrient who enjoys creating responsive, scalable, and maintainable web experiences. She’s passionate about open source, web accessibility, cybersecurity privacy, and blockchain.

Explore related topics

FREE TRIAL Ready to get started?