Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

Short answer: CSS can reliably style the box that contains an embedded PDF—its size, border, spacing, and surrounding layout. It usually cannot restyle the toolbar and page controls inside Chrome, Firefox, Safari, or another browser’s built-in PDF viewer. If you need to redesign those controls, integrate a viewer whose HTML and CSS you control, such as Mozilla’s PDF.js.

First decide which PDF viewer you are styling

An HTML page can display a PDF in several ways. The distinction matters because the visible document area and the viewer controls may belong to different rendering layers.

Approach What your CSS controls When to use it
Native iframe or object The embedding element and its surrounding layout. The browser’s internal PDF toolbar is browser-dependent. A simple, low-maintenance preview or document link.
PDF.js viewer or components Markup, viewer layout, and the styles you include in your application. A branded viewer, custom toolbar, or application-specific controls.
Commercial SDK Vendor APIs for UI, toolbar, and workflow features. Products that also need annotation, signing, form filling, or other document workflows.

PDFObject’s documentation describes targeting an element and receiving an iframe, while Mozilla’s PDF.js documentation separates the core, display, and viewer layers. The PDF.js viewer is intended as a starting point for building a customized viewer; its documentation says it is the UI used by Firefox and related extensions. See Mozilla PDF.js Getting Started and the PDFObject API.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Style a native embedded PDF

For an ordinary document preview, style a wrapper and make the iframe fill it. This controls the dimensions and decoration of the embedding region, not the browser-owned PDF controls.

#1 Best Overall
PDF Reader for Fire Tablet
  • PDF Reader for Fire Tablet
  • ✔Fast PDF Viewer
  • ✔Simple List of PDF Files
  • ✔Share and Print PDF
  • ✔55 Different Themes

Accessible, responsive markup

<div class="pdf-frame">
  <iframe
    src="/documents/guide.pdf"
    title="Product guide"
    loading="eager"
  ></iframe>
  <p class="pdf-fallback">
    Your browser may not display the PDF inline.
    <a href="/documents/guide.pdf">Open or download the product guide</a>.
  </p>
</div>

The title gives screen-reader users a meaningful name. Keep a normal link because a browser, privacy setting, or assistive technology may not provide an inline viewer. PDFObject’s static embedding guide documents the fallback advantage of an object element; the same principle applies when an iframe is your primary route. See PDFObject’s non-JavaScript embedding guide.

Container CSS

.pdf-frame {
  width: 100%;
  height: min(75vh, 54rem);
  min-height: 24rem;
  border: 1px solid #c9ced6;
  border-radius: 0.5rem;
  overflow: hidden;
  background: #f3f5f7;
  position: relative;
}

.pdf-frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.pdf-fallback {
  margin: 0;
  padding: 1rem;
  font: 0.95rem/1.5 system-ui, sans-serif;
}

/* Hide the fallback after the iframe has loaded, if desired. */
.pdf-frame.is-loaded .pdf-fallback {
  display: none;
}

Use a fixed or bounded height rather than relying on the PDF’s intrinsic height; an iframe otherwise has no useful way to size itself to every page. min() keeps the viewer usable on small screens while preventing an excessively tall desktop panel. Add your own responsive breakpoint if the document needs a different mobile height.

Using object with fallback content

<object
  data="/documents/guide.pdf"
  type="application/pdf"
  class="pdf-object"
>
  <p>Inline PDF viewing is unavailable.
    <a href="/documents/guide.pdf">Open the PDF</a>.
  </p>
</object>
.pdf-object {
  display: block;
  width: 100%;
  height: min(75vh, 54rem);
  border: 1px solid #c9ced6;
  border-radius: 0.5rem;
}

An object can expose its fallback markup when inline display is unavailable. Whichever element you choose, test the final result in the browsers and assistive technologies your audience actually uses.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can CSS change the native PDF toolbar?

Not dependably. The page stylesheet applies to your iframe or object element; the browser may render the PDF document and its toolbar in an internal viewer outside your page’s document tree. A selector such as iframe .toolbar therefore cannot be treated as a cross-browser solution. Browser implementations and settings vary, and the cited embedding documentation establishes control of the outer element rather than a universal API for internal controls.

Rank #2

You can still improve the experience around a native viewer:

  • Give the frame a predictable height and a visible focus state.
  • Provide separate “Open” and “Download” links.
  • Place the document title and file size outside the frame.
  • Use a high-contrast border and avoid relying on color alone.
  • Set a language-appropriate page layout around the viewer rather than trying to alter internal buttons.

Use PDF.js when the interface itself must be branded

PDF.js supplies core and display libraries plus a viewer layer containing HTML and CSS. Its distribution includes viewer files, and the component example imports pdf_viewer.css and renders pages inside a .pdfViewer container. Start with the project’s exact release, retain its required markup, and scope your overrides to the instance you own.

Typical integration shape

The exact import paths depend on how you install or bundle PDF.js, so follow the release’s getting-started instructions. The structural pattern is:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<link rel="stylesheet" href="/pdfjs/web/pdf_viewer.css">
<div id="viewer-shell" class="viewer-shell">
  <div class="pdfViewer"></div>
</div>
.viewer-shell {
  height: min(80vh, 60rem);
  overflow: auto;
  background: #e7e9ed;
  color: #20242a;
}

/* Scope overrides so another PDF.js instance is not affected. */
#viewer-shell .page {
  margin: 1rem auto;
  box-shadow: 0 0.25rem 1rem rgb(0 0 0 / 18%);
}

#viewer-shell .textLayer ::selection {
  background: rgb(30 110 230 / 30%);
}

@media (prefers-color-scheme: dark) {
  #viewer-shell {
    background: #20242a;
  }
}

Do not assume every internal class is a permanent public API. Keep your overrides in a separate stylesheet, record the PDF.js version, and check the viewer after upgrades. The PDF.js component example shows the supplied stylesheet and page-container classes.

Rank #3
My PDF Reader
  • Open PDF files easily on your smartphone.
  • Cool User Interface and look.
  • Zoom and pan easily by using gesture with your fingers.
  • Scroll through pages easily vertically.
  • Fullscreen viewing capability.

Change layout without breaking the viewer

  • Let the PDF.js viewer own scrolling where it expects to; avoid putting conflicting overflow rules on nested page elements.
  • Override colors, spacing, and shadows at a scoped shell level first.
  • Do not remove text or annotation layers merely to simplify appearance; those layers support selection and interaction.
  • Use browser developer tools to identify whether a visible control belongs to your app’s DOM or to a PDF.js component.

Set the initial view separately from CSS

PDF.js documents URL options for the starting page, zoom, named destination, and sidebar mode. For example, a viewer URL may use a hash such as #page=3&zoom=page-width&pagemode=thumbs. These values configure initial state; they are not CSS properties and do not replace layout rules.

The viewer-options page was last edited March 7, 2019, so verify the behavior against the PDF.js release you deploy before relying on a particular option: PDF.js Viewer options.

When a commercial SDK is appropriate

PDF.js Express documents a default UI hosted within an iframe and APIs for customizing its UI, toolbar, and menus. Its product pages distinguish a free viewer with limited capabilities from a commercial Plus SDK described as supporting viewing, annotation, signing, and form filling. Treat licensing and current feature availability as a procurement question; the cited pages do not establish partner-program or affiliate availability. See PDF.js Express Default UI and Customize PDF Viewer UI & Toolbar.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Or skip the browser setup

If your goal is a clean image or PDF of a page rather than an interactive in-page document viewer, ScreenshotNeo provides a website screenshot API and MCP server. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers.

One GET request returns PNG, JPEG, WebP, or PDF. The API also supports full-page capture with lazy images loaded, CSS-selector element capture, dark mode, device presets or custom viewports, retina scale, PDF paper and margin settings, custom CSS and JavaScript, clicks, selector or network-idle waits, request blocking, headers, cookies, user agents, authorization, timezone and geolocation, transparent backgrounds, resizing, configurable caching, signed links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, usage data, and an OpenAPI specification. Its parameter names are compatible with those used by many screenshot APIs.

Rank #4
PDF Viewer Plus, pdf reader
  • View pdf files
  • Merge Pdf files
  • Compress pdf files
  • Night mode
  • Snap to page

cURL:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

See the ScreenshotNeo documentation for parameters and response handling. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting checklist

The frame is blank or only a thin strip

Check that every ancestor has a usable width and that the iframe or object has an explicit height. A percentage height resolves to zero when its parent’s height is undefined. Inspect the computed styles and try the bounded min(75vh, 54rem) value shown above.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The PDF downloads instead of opening

The server may send a download-oriented Content-Disposition header, the browser may lack an inline PDF viewer, or an organization policy may disable it. Keep the download link as the intentional fallback. If you control the response, verify its media type is application/pdf and test the deployment’s headers.

My toolbar CSS has no effect

You are probably targeting a browser-owned viewer rather than your page’s DOM. Move the customization to PDF.js or an SDK with a documented UI API. Do not depend on browser-specific shadow DOM behavior.

Best Value
PDF Reader For Fire Tablet & Ebook Reader, Viewer, Editor, Convertor, Merge, Split & Compress
  • Fast & Smooth PDF Reader – Open, view, and read PDF files with ease.
  • Dark Mode Support – Comfortable reading experience at night.
  • Quick Search & Bookmarking – Find text and save favorite pages instantly.
  • Annotate & Edit PDFs – Highlight, underline, and add comments.
  • Merge & Split PDFs – Combine or separate pages easily.

PDF.js overrides break after an update

Compare the deployed release’s markup and stylesheet with your override selectors. Scope rules to your shell, avoid broad selectors such as .button, and update your visual and keyboard tests whenever PDF.js changes.

Pages or images appear incomplete

For an interactive PDF.js viewer, check its loading and worker configuration. For a static capture, use a wait for a selector, delay, or network idle condition; lazy-loaded content may require full-page capture and additional wait time.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Practical decision guide

  1. Choose a native iframe or object when you only need a document inside a styled panel.
  2. Add a meaningful label, explicit dimensions, and an open/download fallback.
  3. Choose PDF.js when you need control over the toolbar, sidebar, theme, or page layout.
  4. Keep viewer state options such as page and zoom in the viewer URL, not in CSS.
  5. Choose a commercial SDK when document workflows such as annotation or signing justify its licensing and integration model.

Frequently Asked Questions

Can I hide the browser PDF toolbar with CSS?

Not as a dependable cross-browser technique. The toolbar may be rendered by the browser’s internal PDF viewer, outside the embedding page’s CSS scope.

Why does my iframe ignore height: 100%?

Percentage heights require an ancestor with an explicit height. Give the wrapper a fixed, viewport-based, or otherwise bounded height first.

Is PDF.js only for displaying PDFs?

It provides core, display, and viewer layers that can be integrated into a custom application. Additional workflow features may require a separate SDK.

Should I use an iframe or object element?

Use whichever fits your fallback and browser requirements. Both can embed a PDF, but an object provides a natural fallback-content area when inline display is unavailable.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Quick Recap

Bestseller No. 1
PDF Reader for Fire Tablet
PDF Reader for Fire Tablet
PDF Reader for Fire Tablet; ✔Fast PDF Viewer; ✔Simple List of PDF Files; ✔Share and Print PDF
$2.99
Bestseller No. 2
PDF Reader, PDF Viewer, PDF Editor- file document
PDF Reader, PDF Viewer, PDF Editor- file document
PDF Reader; PDF Viewer; PDF Editor
$6.85
Bestseller No. 3
My PDF Reader
My PDF Reader
Open PDF files easily on your smartphone.; Cool User Interface and look.; Zoom and pan easily by using gesture with your fingers.
Bestseller No. 4
PDF Viewer Plus, pdf reader
PDF Viewer Plus, pdf reader
View pdf files; Merge Pdf files; Compress pdf files; Night mode; Snap to page; Horizontal View
Bestseller No. 5
PDF Reader For Fire Tablet & Ebook Reader, Viewer, Editor, Convertor, Merge, Split & Compress
PDF Reader For Fire Tablet & Ebook Reader, Viewer, Editor, Convertor, Merge, Split & Compress
Fast & Smooth PDF Reader – Open, view, and read PDF files with ease.; Dark Mode Support – Comfortable reading experience at night.
$2.99

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.