How to Adjust Margins for Markdown PDF — @page, Print Dialog, and mm Settings
Why Markdown PDF margins feel wrong—@page vs body padding, browser print dialog presets, asymmetric binding margins, and mm specs. Fix and verify margins step by step.
What you'll learn
- How PDF margins are determined (CSS layers + print dialog interaction)
- The difference between
@pageandbodypadding for margin control - When browser print dialog presets conflict with CSS margin rules
- How to set asymmetric margins for bound/stapled documents
- How headers, footers, and page numbers eat into the margin area
- Why mm and pt/px sometimes show 1–2 mm rounding differences
In PDFs, margins are the distance from the paper edge to the body. Markdown has no margin syntax—after HTML conversion, CSS print styles and the browser print dialog together decide the result. When margins feel "wrong," check whether @page and body padding and the dialog's margin preset are fighting each other.
Where margins live
Typically @page { margin: … } sets page-level margins, and body { padding: … } adjusts inner spacing. Some tools expose mm fields in layout settings that map to these rules internally. In print preview, set paper size (A4, etc.) and orientation—changing paper changes the effective text width even with the same numbers.
Browser print dialog
Presets like "minimal margins" or "none" can add to or override CSS margins. If on-screen preview looks fine but Save as PDF shifts layout, reset dialog margins to default once and retry. Comparing Chromium vs Firefox vs Safari helps you see engine differences.
Left vs right binding
For stapled or bound handouts, you may need asymmetric margins—extra gutter on the binding side. When the tool allows per-side values, enter them there. Symmetric on screen can still read better on paper with one wider inside margin.
With a cover or table of contents
Adding a cover or TOC changes where body text visually begins. Decide whether margins are global or different on the cover; when exporting with a cover, skim page 1 of the body for awkward whitespace.
Headers, footers, page numbers
Some print paths inject date, URL, or page numbers into the margin area, making the body feel cramped. That layer is not the same as @page margin alone. If a spec says "margin X mm," confirm whether that includes running headers or only the main text block.
Zoom and on-screen review
Zoomed viewing can make margins feel larger or smaller than print. For a print judgment, use 100% or a true-size preview when possible. OS display scaling plus browser zoom changes perceived proportions.
mm vs pt vs px
Print margins are often specified in mm; CSS may mix pt and px. Rounding can make margins feel 1–2 mm off. For strict specs, print and measure with a ruler. Teams can pin margin numbers in a README so handoffs stay consistent.
This app
Markdown to PDF lets you set margins, fonts, line height, max width, and more from layout settings. With a cover template, tune layout assuming the same rules apply to body pages unless you override.
FAQ
I set 20 mm margins but they look wider than expected
The browser print dialog may have a preset like "minimum" or "default" that adds to your CSS margins. Open the print dialog and set it to "Default" or "None", then check the result again.
Can I set left and right margins independently?
Yes. Layout settings in this app allow per-side mm values. For bound documents, set a wider inside margin (typically left for left-binding).
Margin-zero settings cut off the edge text
Printers have a non-printable zone. Keep at least 5–10 mm of margin to avoid clipping.
How do I remove the header/footer (URL, date, page number)?
In Chrome's print dialog, expand More settings and uncheck Headers and footers. Other browsers have similar options.
A4 and Letter look different with the same mm setting
Changing paper size changes the proportion of the margin relative to text area. Match the paper size in layout settings to the print dialog for consistent results.
Summary
Margins are CSS plus the print dialog. After changing numbers, always print-preview. On multi-page docs, if odd/even pages feel uneven, recheck binding and header/footer visibility.
Related
- How-to & BlogWhy Markdown PDFs and Print Look Broken — Causes and FixesFix common Markdown-to-PDF and print issues—margins, breaks, missing backgrounds, font substitution, overflowing tables. Includes a triage checklist and browser comparison notes.Read article
- How-to & BlogBetter-Looking Markdown PDFs — Layout, Page Breaks, and a Practical Polish ChecklistImprove Markdown PDF visual quality: align screen vs print layout, fix margins, fonts, overflowing tables and code blocks, add cover pages and TOC. Includes a pre-delivery polish checklist.Read article
- How-to & BlogHow to Convert Markdown to HTML and PDF — Step-by-Step GuideFull guide to Markdown Document Converter: load files, switch view modes, tweak layout, download HTML, save PDF. Step-by-step with screenshots and FAQ for first-time users.Read article