Web page to PDF: paper sizes, margins and print CSS
A PDF of a web page is made of sheets, and every sheet has the same parts. This reference gives each paper size in millimetres, inches, CSS pixels and points, shows how margins and page breaks work, and lists the CSS that controls them.
The anatomy of a printed page
Paper edge. The sheet itself.
210 × 297 mm, 794 × 1123 px · @page { size: A4 }
Margin. The band between the paper edge and the content.
20 mm, 75.6 px on each side · @page { margin: 20mm }
Page area. Where the content is laid out. Its width is the layout width of the document.
170 × 257 mm, 643 × 971 px · paper minus margins
Header zone. The margin boxes along the top edge.
Inside the 20 mm top margin · @top-left, @top-center, @top-right
Footer zone. The margin boxes along the bottom edge. Page numbers go here.
Inside the 20 mm bottom margin · @bottom-left, @bottom-center, @bottom-right
Page break. Where one page area ends and the content carries on in the next.
Every 257 mm of content · break-before, break-after, break-inside
Paper sizes to scale: A4, Letter and the rest
A4 is 5.9 mm narrower and 17.6 mm taller than US Letter, so a document laid out for one never fits the other exactly. The two families are built differently: ISO 216 sizes are defined in millimetres and North American sizes in inches.[1]
- Each ISO A size is the one before it cut in half across its long side, with halves rounded down to a whole millimetre: A3 is 297 × 420 mm, A4 is 210 × 297 mm, A5 is 148 × 210 mm.
- Every A sheet has the same shape, 1 to the square root of 2 (about 1.414), so a page scales from A4 to A3 or A5 without reflowing. Letter is 1 to 1.294 and Legal 1 to 1.647.
- Tabloid is two Letter sheets side by side: 11 × 17 in. Ledger is the same sheet in landscape, 17 × 11 in.[8]
What size is A4 in pixels?
A4 is 794 × 1123 CSS pixels and US Letter is 816 × 1056. CSS fixes the pixel at 1/96 of an inch and the point at 1/72 of an inch, so every paper size has exactly one size in pixels and one in points, whatever the resolution of the printer.[2]
px = inches × 96
8.5 in × 96 = 816 px
px = mm × 96 / 25.4
210 mm × 96 / 25.4 = 793.70 px
pt = inches × 72
the same as px × 0.75
- A03179 × 4494 px · 2384 × 3370 pt841 × 1189 mm · 33.11 × 46.81 in
- A12245 × 3179 px · 1684 × 2384 pt594 × 841 mm · 23.39 × 33.11 in
- A21587 × 2245 px · 1191 × 1684 pt420 × 594 mm · 16.54 × 23.39 in
- A31123 × 1587 px · 842 × 1191 pt297 × 420 mm · 11.69 × 16.54 in
- A4794 × 1123 px · 595 × 842 pt210 × 297 mm · 8.27 × 11.69 in
- A5559 × 794 px · 420 × 595 pt148 × 210 mm · 5.83 × 8.27 in
- A6397 × 559 px · 298 × 420 pt105 × 148 mm · 4.13 × 5.83 in
- Letter816 × 1056 px · 612 × 792 pt215.9 × 279.4 mm · 8.5 × 11 in
- Legal816 × 1344 px · 612 × 1008 pt215.9 × 355.6 mm · 8.5 × 14 in
- Tabloid1056 × 1632 px · 792 × 1224 pt279.4 × 431.8 mm · 11 × 17 in
Portrait, width × height. Pixels and points are rounded to the nearest whole number and inches to two decimals. Only the North American pixel figures are exact, because those sizes are defined in inches. CSS has size keywords for ten sheets (A5, A4, A3, B5, B4, JIS-B5, JIS-B4, letter, legal, ledger); any other sheet is written as two lengths, such as size: 105mm 148mm.[3] Chromium-based tools define the A sizes in inches rounded to two decimals (A4 as 8.27 × 11.7 in), so a page they report can differ from the ISO figure by one pixel.[8]
How wide is the content after the margins?
The content area is the paper minus the margins, and its width is the width the page is laid out at. A4 with a 20 mm margin leaves 170 × 257 mm, which is 643 × 971 px. That is narrower than most tablets.
| Paper | Margin | Area in mm | Area in px |
|---|---|---|---|
| A4 | 0 | 210 × 297 | 794 × 1123 |
| A4 | 10mm | 190 × 277 | 718 × 1047 |
| A4 | 15mm | 180 × 267 | 680 × 1009 |
| A4 | 20mm | 170 × 257 | 643 × 971 |
| A4 | 1in | 159.2 × 246.2 | 602 × 931 |
| Letter | 0 | 215.9 × 279.4 | 816 × 1056 |
| Letter | 0.5in | 190.5 × 254 | 720 × 960 |
| Letter | 0.75in | 177.8 × 241.3 | 672 × 912 |
| Letter | 1in | 165.1 × 228.6 | 624 × 864 |
Why does a web page look different as a PDF?
A web page looks different as a PDF because three things change at once: the print styles switch on, the backgrounds switch off, and the layout shrinks to the width of the paper.
On screen
1280 px wide
As a PDF
794 px wide
A breakpoint on paper
The print media type is active
A browser that prints applies the rules inside @media print and skips the ones inside @media screen. Sites use that to hide menus, sidebars and cookie banners and to switch to a single column.[11]
To keep the screen look in a PDF, the tool that makes it has to emulate the screen media type.
Backgrounds are left out by default
print-color-adjust starts at economy, which lets the browser drop background colours and images and darken pale text to save ink. Print dialogs and PDF libraries usually ship with the background switch off.[7][8]
Turn on background graphics in the tool, and set print-color-adjust: exact on the elements whose colours carry meaning.
The layout is as wide as the paper, not the window
On paper the layout width is the page area: the paper width minus the left and right margins. A4 with no margin is 794 CSS pixels wide, about the width of a tablet in portrait, so width media queries pick the tablet or phone layout.[1]
Use landscape or a larger sheet for wide layouts, or write print rules that do not depend on the window width.
The print CSS cheat sheet
Nine pieces of CSS control how a page prints: the sheet, the margins, where pages break, what keeps its colour and what repeats. The versions are the first release of each browser with support, from MDN compatibility data.[12]
Paper size and margins
Sets the sheet and the margin for every page of the document.[1][3][12]
CSS /* also: letter, A3 landscape */ @page { size: A4; margin: 20mm; }CSS has keywords for A5, A4, A3, B5, B4, JIS-B5, JIS-B4, letter, legal and ledger. Any other sheet is written as two lengths. Safari does not support the portrait and landscape keywords.
Chrome 15+Firefox 95+Safari 18.2+
A different first page
Styles only the first printed page. :left and :right style the two sides of a spread.[1][12]
CSS /* room for a letterhead on page one */ @page :first { margin-top: 40mm; }Firefox does not support :left and :right.
Chrome 18+Firefox 116+Safari 6+
Page breaks
Forces a break before an element, or keeps a block or a heading and its text together.[5][12]
CSS /* start on a new page */ h2 { break-before: page; } /* never split in two */ figure, tr { break-inside: avoid; } /* keep a heading with what follows */ h2, h3 { break-after: avoid-page; }Firefox does not support avoid-page (or plain avoid) on break-before and break-after; break-inside: avoid works in all three.
Chrome 50+Firefox 65+Safari 10+
Legacy page-break aliases
The older page-break-* properties still work: browsers treat them as aliases of break-*.[5]
CSS /* the same as break-before: page */ h2 { page-break-before: always; } /* the same as break-inside: avoid */ figure { page-break-inside: avoid; }The alias maps always to page. Write both forms only if you must support very old engines.
Chrome yesFirefox yesSafari yes
Orphans and widows
Sets the fewest lines of a paragraph that may stand alone on either side of a break. Both start at 2.[6][12]
CSS p { orphans: 3; /* lines left at the bottom */ widows: 3; /* lines carried to the top */ }Firefox supports neither property.
Chrome 25+Firefox noSafari 1.3+
Keep backgrounds and colours
Tells the browser not to drop or alter the backgrounds and colours of these elements in print.[7][12]
CSS .badge, thead th { /* the prefixed line is for Chrome before 136 */ -webkit-print-color-adjust: exact; print-color-adjust: exact; }Chrome took the -webkit- prefix from version 17 and the plain name from 136. Chrome and Safari do not print the background of the body element itself, and a user setting can still override the property.
Chrome 136+Firefox 97+Safari 15.4+
Rules for paper only
Applies only when the page is printed or saved as a PDF: hide the navigation, set type in points, print link addresses.[11]
CSS @media print { nav, aside, .cookie-banner { display: none !important; } body { font-size: 11pt; } a[href^="http"]::after { content: " (" attr(href) ")"; } }Chrome yesFirefox yesSafari yes
Repeat table headers
A real thead is a table header group, which print engines may repeat on every page the table spans.[10]
HTML <table> <thead><tr><th>Item</th><th>Price</th></tr></thead> <tbody>...</tbody> </table>CSS says "may", so treat a repeated header as likely, not guaranteed, and test in the engine you print with. A header built from div elements never repeats.
Running header and page numbers
Puts text and page numbers in the 16 margin boxes around the page area.[1][4][12]
CSS @page { @top-center { content: "Quarterly report"; } @bottom-right { content: counter(page) " / " counter(pages); } }Chrome 131 and later only. The margin has to be wide enough to hold the text: with a zero margin there is nowhere to draw it.
Chrome 131+Firefox noSafari no
What does not work everywhere
How to read the badges: a number is the first version of that browser with support, and a grey badge means no released version supports it as of October 2026. A card without badges has no entry in the compatibility data.
Which PDF settings should you choose?
Four choices decide what a PDF of a web page looks like. Each one has a short rule.
One long page or real pages?
- Real pages
- when the PDF will be printed, signed, filed next to other documents, or needs page numbers.
- One long page
- when the PDF is read on a screen or kept as a record of how the page looked: no break can cut an image or a table in two.
A4 or Letter?
- Letter
- when the reader is in one of the 14 territories where it is the default: United States, Canada, Mexico, Belize, Chile, Colombia, Costa Rica, El Salvador, Guatemala, Nicaragua, Panama, Philippines, Puerto Rico, Venezuela.[9]
- A4
- when the reader is anywhere else, or you do not know. A4 is the default for the rest of the world.
Portrait or landscape?
- Portrait
- when the content is text: articles, invoices, letters, contracts. Lines stay a comfortable length.
- Landscape
- when the content is wide: tables with many columns, dashboards, charts, slides. A4 landscape gives the layout 1123 pixels instead of 794.
Print backgrounds?
- On
- when the PDF should look like the page: brand colours, table stripes, charts, code blocks, dark headers.
- Off
- when the PDF goes to a printer and ink matters, or the page has a dark theme that would print as a solid block.
PDF options in the CurlShot API
CurlShot turns a web page into a PDF when a request carries format=pdf. The defaults are A4, portrait, no margin, backgrounds printed and the screen layout, and a PDF always covers the whole page from top to bottom.
Show the table
| API option | What it does | Accepted values | Default | CSS equivalent |
|---|---|---|---|---|
| pdf_paper_format | The paper size of every page. | a0, a1, a2, a3, a4, a5, a6, letter, legal, tabloid, ledger | a4 | @page { size: A4 } |
| pdf_landscape | Turns the paper on its side. | true, false | false | @page { size: A4 landscape } |
| pdf_margin | The margin on all four sides. | a length in mm, cm, in or px; a bare number is pixels | no margin | @page { margin: 20mm } |
| pdf_margin_top, _right, _bottom, _left | One side at a time. Each wins over pdf_margin for its side. | the same lengths | the value of pdf_margin | @page { margin-top: 20mm } |
| pdf_print_background | Prints background colours and images. | true, false | true | print-color-adjust: exact, and "Background graphics" in a print dialog |
| pdf_fit_one_page | One PDF page as tall as the content, up to 150 inches (14,400 px). Paper format and landscape are not used. | true, false | false | @page { size: <width> <content height> } |
| media_type | Which set of styles the page is drawn with. | screen, print | screen | @media screen and @media print |
The paper comes from pdf_paper_format. The API adds no header, footer or page numbers of its own, and it has no separate zoom option for PDF. Two image options, selector and clip_*, are refused together with format=pdf.
curl "https://curlshot.com/api/v1/screenshot?access_key=YOUR_ACCESS_KEY\
&url=https://example.com\
&format=pdf\
&media_type=print\
&pdf_paper_format=a4\
&pdf_margin=20mm" \
--output page.pdfThis request returns page.pdf: the print layout of the page on A4 with a 20 mm margin. That is the sheet in the drawing at the top of this article, with a content area of 170 × 257 mm.
For many pages at once, see how to archive pages as PDF.
Glossary: the words on the page
- Page box
- The rectangle CSS lays one printed page out in. It maps to one side of a sheet of paper and is made of the page area in the middle and the margin around it.
- Page area
- The content area of the page box: the paper minus its margins. The page area of the first page sets the width the whole document is laid out in.
- Margin box
- One of the 16 boxes that divide the margin of a page: four corners and three along each edge, such as @top-center and @bottom-right. Running headers and page numbers go there.
- Bleed
- The extra band outside the trimmed page that ink is allowed to run into, so a colour that reaches the edge has no white sliver after the paper is cut. It matters for commercial printing, not for a PDF read on a screen.
- CSS pixel
- The px unit: exactly 1/96 of a CSS inch. On paper a CSS inch is a real inch, so 96 CSS pixels cover 25.4 mm whatever the resolution of the printer.
- Point
- The pt unit: 1/72 of an inch, so 1 pt is 1.3333 px and 12 pt is 16 px. PDF files measure pages in points: A4 is 595 × 842 pt.
- Print media
- The media type a browser uses when it prints or saves a PDF. Rules inside @media print apply and rules inside @media screen do not.
Questions people ask
What size is A4 in pixels?
A4 is 794 × 1123 CSS pixels at 96 pixels per inch (793.70 × 1122.52 before rounding). At 72 per inch, the unit PDF files use, A4 is 595 × 842 points. At 300 dots per inch, a common printer resolution, the same sheet is 2480 × 3508 dots.
What size is US Letter in pixels?
US Letter is exactly 816 × 1056 CSS pixels at 96 pixels per inch, because it is defined in inches: 8.5 × 11. In points it is 612 × 792, and in millimetres 215.9 × 279.4.
Why does my web page look different when I save it as a PDF?
Three things change. The browser switches to the print media type, so rules inside @media print apply. Background colours and images are left out unless background printing is on. And the layout becomes as wide as the paper minus its margins, about 794 pixels for A4, so the page picks its tablet or phone layout.
How do I set the page size and margins of a PDF with CSS?
Use the @page rule: @page { size: A4; margin: 20mm } sets the sheet and the margin of every page. The size takes a keyword such as A4, A3, A5, letter or legal, optionally with portrait or landscape, or two lengths such as 210mm 297mm.
How do I stop a page break from splitting a table row or an image?
Set break-inside: avoid on the element, for example on tr, figure or a card. It works in Chrome, Firefox and Safari. To start a section on a new page use break-before: page. The older page-break-inside and page-break-before properties are aliases of these and still work.
Can CSS add page numbers to a PDF?
In Chrome 131 and later, yes: put content: counter(page) " / " counter(pages) in a page margin box such as @bottom-right inside @page. Firefox and Safari do not support margin boxes, so there the numbers come from the print dialog or from the tool that makes the PDF.
Which paper sizes does CurlShot support for PDF?
CurlShot accepts a0, a1, a2, a3, a4, a5, a6, letter, legal, tabloid and ledger in pdf_paper_format, with a4 as the default. pdf_landscape turns the sheet, pdf_margin sets the margins, and pdf_fit_one_page puts the whole page on one sheet as tall as the content.
Sources
- [1]W3C, CSS Paged Media Module Level 3 (Working Draft, 14 September 2023). Checked .
- [2]MDN Web Docs, <length>: absolute length units. Checked .
- [3]MDN Web Docs, @page: the size descriptor. Checked .
- [4]Chrome for Developers, Add content to the margins of web pages when printed using CSS. Checked .
- [5]MDN Web Docs, break-before. Checked .
- [6]MDN Web Docs, widows. Checked .
- [7]MDN Web Docs, print-color-adjust. Checked .
- [8]Playwright, Page.pdf(): paper formats, margins and defaults. Checked .
- [9]Unicode Consortium, CLDR supplemental data: paperSize. Checked .
- [10]W3C, CSS 2, chapter 17: tables (table-header-group). Checked .
- [11]MDN Web Docs, Printing. Checked .
- [12]MDN browser-compat-data, Browser compatibility data for @page (with the break-*, orphans, widows and print-color-adjust files beside it). Checked .
Read next
- ComparisonPNG, JPEG, WebP or PDF for website screenshotsA decision flow, a comparison table and our own file-size measurements for choosing PNG, JPEG, WebP or PDF when you save a screenshot of a web page.
- ChecklistCapture a web page as evidence that holds upA checklist for saving a web page as a credible record: what to capture, how to fix the time with a hash and timestamp, and what makes a screenshot weak.
- Cheat sheetViewport sizes cheat sheet: phones to desktopsViewport sizes in CSS pixels, screenshot sizes and device pixel ratios of iPhone, Pixel, Galaxy, iPad and laptop screens, drawn to scale, and the sizes to test.