You designate an HTML page for printed output by combining three things: a print-targeted stylesheet linked with media="print" (or @media print blocks), a @page rule that sets paper size and margins, and print-aware rules that control page breaks, link URLs, and color. There's no single print="true" attribute; the designation happens entirely in CSS plus a well-structured document. The key condition is that screen styles must be separated from print styles so browsers can apply the right rules when a user hits Print, Save as PDF, or a headless renderer generates a document.
That distinction matters because print isn't just "the screen, smaller." Paper has fixed dimensions, no scrolling, no hover states, and unreliable color reproduction. A page that looks fine on a 1440px monitor can hemorrhage content off the right margin or split a table row across two sheets. The techniques below walk through how to declare print intent, how to verify it, and where the approach breaks down.
Start With the Link Tag and Media Attribute
The oldest and most explicit designation is a stylesheet link with a media query baked in. Browsers download print stylesheets and apply them only during print rendering.
You can also use media="all" for shared base styles and layer print overrides on top. The cascade order matters: later rules with equal specificity win, so put print.css after your base sheet.
One caveat that trips people up: browsers still fetch print.css on page load in most modern engines, so it isn't a lazy-loading trick. What it does guarantee is that the rules only apply during print. If you want to avoid even the download, you'd need JavaScript or a build step, and that's rarely worth it for a stylesheet of a few kilobytes.
A newer option is the media attribute with a comma-separated list: media="print, screen and (min-width: 1200px)" lets a single sheet serve both large screens and paper. Use this sparingly—it couples two very different rendering contexts and makes debugging harder.
Inline Media Queries Inside a Single Stylesheet
If you'd rather keep one file, wrap print rules in @media print:
This is functionally equivalent to the separate media="print" link and is often preferable when the print rules are few. The tradeoff is file size and cognitive load: a 400-line stylesheet where 60 lines are print-only means every screen developer scrolls past rules they don't care about. For anything beyond a small site, a dedicated print.css is easier to reason about.
Both approaches designate the page for print. Neither requires a special HTML attribute or meta tag. If you've seen media="print" referenced in older tutorials alongside media="handheld" (a category that never gained real support), ignore the handheld part—print is the one that survived.
The @page Rule: Paper Size, Margins, and Named Pages
The @page at-rule is what makes print output feel deliberate rather than accidental. It controls the page box—the physical sheet and its margins—separate from the element box model.
size accepts named paper sizes (Letter, A4, Legal, A5) or explicit dimensions (8.5in 11in). margin sets printable margins; browsers also have their own default margins the user can override in the print dialog, and your CSS margins are added to or constrained by that dialog depending on the browser. That's a frequent source of surprise: setting margin: 0 in CSS doesn't guarantee edge-to-edge printing, because the user's print dialog margin setting can still impose a border. For truly borderless output you need @page { margin: 0 } and the user selecting "None" for margins in the dialog—or a headless renderer configured with zero margins.
Named pages let you vary layout by section. This is genuinely useful for documents with a landscape table in the middle:
The page property on the element assigns it to the named page. Support is solid in Chromium-based browsers and Firefox; Safari has historically been patchier with named pages, so test there if it's a target.
You can also target the first page specifically with @page :first, which is handy for suppressing a running header on a cover sheet. :left and :right pseudo-classes let you mirror margins for double-sided printing—wider inner margin, narrower outer—though again, verify in your target browsers.
Controlling Page Breaks
Nothing wrecks a printed page faster than a heading stranded at the bottom of sheet one with its paragraph on sheet two, or a table row sliced in half. Break control is where print CSS earns its keep.
The modern properties are break-before, break-after, and break-inside, which superseded the older page-break-* properties (those still work as aliases in most browsers, but new code should use break-*).
break-inside: avoid on a table tells the renderer not to split it across pages if it fits on one; if the table is taller than a page, the browser will break it anyway, because the alternative is clipping content. That's a hard limit worth knowing: you cannot force a renderer to keep an oversized element whole.
For long tables, thead repeats on each page automatically in most browsers—display: table-header-group is the default for , and that's what triggers repetition. If you're using div-based tables for layout, you lose this for free.
A subtle gotcha: break-after: avoid on a heading works only if the following element can also fit. If a heading is followed by a 900px-tall figure, the browser may still break between them because keeping them together is impossible. Chain the avoidance to the actual content block, not just the heading.
Hiding and Revealing Content for Paper
The display: none trick handles navigation, sidebars, cookie banners, and interactive controls. But print also benefits from content that doesn't appear on screen at all—a URL after each link, a "printed on" date, or expanded abbreviations.
This is one of the highest-value print rules and almost nobody ships it. A printed page with bare "click here" links is useless; appending the href makes the document self-contained. The downside is visual noise on link-dense pages, so scope it—maybe only apply to links inside the main article, excluding the footer.
Conversely, some screen content should stay but change form. A collapsible FAQ that's collapsed on screen should expand for print:
Browser behavior for printing has improved but remains inconsistent across engines and versions, so if expanded FAQ content is critical, consider duplicating it in a print-only container rather than relying on details being forced open.
Color, Backgrounds, and the "Background Graphics" Checkbox
Browsers default to not printing background colors and images, because ink is expensive and most backgrounds are decorative. Your carefully designed dark header will print as white with black text unless the user checks "Background graphics" in the print dialog.
You can't force that checkbox from CSS. What you can do is design for the default: make sure text remains legible without backgrounds, and use borders or outline (which does print) instead of background fills for anything meaningful. A highlighted callout box with a colored background becomes an invisible box when backgrounds are off—add a border so the structure survives.
For elements where a background is essential, print-color-adjust: exact (and the -webkit- prefixed version) hints to the renderer that the color should be preserved. It's a hint, not a guarantee, and it still respects some user settings. Test it rather than assuming.
Also worth checking: box-shadow generally doesn't print, and filter effects may be dropped or approximated. Keep print styles flat.
Fonts, Units, and Reading Distance
Print units are physical. pt (points) is the traditional choice for type, and in, cm, and mm work for margins and dimensions. Pixels technically map to a device-independent unit in print rendering, but the conversion is notional—a 16px body font renders at roughly 12pt in most engines, which is acceptable but not precise. If print fidelity matters, declare sizes in points.
Web fonts add a wrinkle: they can print, but the renderer may time out waiting for a font to load and fall back. A serif stack with reliable system fonts is the safer choice for print. If you must use a web font, self-host it and ensure it's loaded before the print event—hard to guarantee for user-initiated printing, which is another argument for a robust fallback stack.
Reading distance also differs. A screen viewed at 20 inches versus paper at 12 inches means print text can be slightly smaller in absolute size and still comfortable, but line length should be shorter relative to the page. Columns that were 700px wide on screen might become 3.5 inches on a Letter page—narrower in physical terms, which is fine, but margins and gutters should be reconsidered rather than inherited.
Verifying the Designation
You can't fully trust a browser's print preview, because browsers render print preview at their own zoom and sometimes with their own margin overrides. Still, it's the fastest check. In Chrome, Ctrl+P (Cmd+P on macOS) opens the preview; Firefox's preview is similarly competent. Look specifically for:
Content cut off at the right edge (indicates fixed widths not constrained) Headings at the bottom of pages (break control missing) Tables split mid-row (missing break-inside: avoid) Missing background fills (expected; verify legibility without them) URLs on links (verify your ::after rule applied)
For deterministic output, a headless renderer is the better tool. Chromium's headless mode can print to PDF from a URL or local file, and it respects @page size and margins if you configure the print parameters. The command-line interface changes between versions, so check your installed version's --help output rather than trusting a remembered flag. The principle is stable: headless rendering applies print CSS and produces a fixed PDF you can inspect page by page—far more reliable than eyeballing a preview.
A quick success check: convert to PDF, then open the PDF and count pages, scan for orphaned headings, and check that every link's URL is visible. If all three pass, your designation worked.
Common Failure Modes and What Causes Them
Fixed-width containers overflow. A width: 960px wrapper doesn't shrink to the page. Override it in print: width: auto, max-width: 100%. The same applies to min-width, which is the sneakier culprit because it resists shrinking.
Floats and flex collapse or stack oddly. Flexbox and grid mostly work in print, but some engines handle multi-page grid layouts poorly—a grid that spans pages may break in unpredictable places. For long documents, consider switching to block flow in print.
Sticky and fixed positioning misbehave. A position: fixed header intended to persist on screen either repeats on every printed page (in some engines) or appears only once, depending on rendering. Neither is usually what you want. Set position: static in print for anything fixed.
Viewport units have no meaning. 100vh refers to the screen, not the page. In print it can resolve to the page height in some engines and to something arbitrary in others. Avoid viewport units in print styles entirely.
Screen-only JavaScript doesn't run. If content is injected on load and the print capture happens before injection completes, you get blank regions. For headless PDF generation, wait for network idle and a rendering delay; for user-initiated printing, the page is already rendered, so this is less of an issue—but lazy-loaded images may still be missing if the user never scrolled to them.
@page margins conflict with the dialog. As noted earlier, user or renderer margins compound with CSS margins. If output looks like it has double margins, check both places.
A Minimal Working Template
Putting it together, a complete designation for a typical article page looks like this:
That's the whole designation: two link tags, an @page rule, and a handful of @media print overrides. No meta tag, no attribute on , no JavaScript required.
Where This Breaks Down: PDF Generators and Email Clients
Browser printing is the common case, but two others deserve mention because they change what "designated for print" means.
Server-side PDF generation (Puppeteer, Playwright, wkhtmltopdf, and similar) uses a rendering engine that honors print CSS to varying degrees. Chromium-based generators honor @page, break-, and print-color-adjust well. Older engines like wkhtmltopdf use a WebKit fork with partial support—named pages and some break- values may be ignored. If your PDF pipeline uses an older engine, the @page margins you set may be overridden by CLI flags, and background printing may need an explicit --background flag. Check your generator's documented support rather than assuming browser parity.
Email clients that offer a print function render the email's HTML through the client's own engine, which rarely honors your stylesheet. If printable email matters, the realistic approach is a plain, table-based layout that degrades gracefully—there's no reliable way to attach @page rules to an email and have them applied.
The unifying principle: designation via media="print" and @page is standardized and well-supported in browsers, but "print" also means "whatever engine the consumer uses." For a webpage opened in a browser, the techniques here are dependable. For anything routed through a custom renderer, verify against that renderer.
A Worked Estimate: How Many Pages Will This Produce?
You can approximate page count before printing, which is useful for deciding whether a long article needs a table of contents or a break-before on major sections. Assume Letter paper (11 inches tall) with 0.8-inch top and bottom margins: usable height is 9.4 inches. At 11pt type with 1.45 line-height, a line occupies about 11 × 1.45 = 15.95pt, or roughly 0.221 inches. That gives about 42 lines per page.
If your article body has 1,800 words at an average of 14 words per line, that's about 129 lines of body text, or roughly 3.1 pages of uninterrupted prose. Add headings, figures, and spacing and you might land at 4–5 pages. This is a rough estimate—line length varies with characters per line, paragraphs waste space at page ends, and figures consume more than their nominal height. Treat the number as an input to layout decisions, not a promise. If the estimate comes out at 40 pages, that's a signal the document wants a table of contents and deliberate chapter breaks rather than a print stylesheet tweak.
Practical Order of Operations
If you're designating an existing page today, work in this order and check the print preview after each step:
1: Add the media="print" link or @media print block. Check that nothing looks worse. 2: Set @page size and margins. Check that content fits within the page width. 3: Hide non-content elements. Check that the article stands alone. 4: Add break control to headings, figures, tables, and code blocks. Check for orphaned headings and split rows. 5: Append link URLs and expanded abbreviations. Check for clutter. 6: Override fixed widths and positioning. Check the right edge and any fixed headers. 7: Convert to PDF via a headless renderer and inspect page by page.
Stop adjusting once the PDF passes the URL/heading/row checks. Further pixel-tweaking has diminishing returns because the user's print dialog can override much of it anyway.
The one thing to get right before anything else: separate the print styles from the screen styles. Everything else—@page, break control, link URLs—builds on that separation. Get the separation wrong, and every subsequent fix fights the cascade.