Problem: Screen and Print Are Different Worlds
The page looks perfect on the monitor, but when printed turns into a mess of cropped banners, sticky headers, tiny text, and unreadable links. 70% of users encounter this issue. A proper website print setup is essential. Print CSS reduces document preparation time for printing by half and cuts paper usage by 30%, saving up to 40% on costs. Compared to manually formatting each page, our print CSS solution reduces setup time by 3x and cuts paper usage by 40%. We solve this with a properly configured print CSS — a separate set of rules and minimal JavaScript. Our track record: over 50 successful projects, guaranteed results. Our solution saves you money – for example, one client saved $500 per month after implementation.
We develop custom print styles that work across all browsers.
Why Print CSS Is a Separate Discipline?
Screen styles are not suitable for paper. Different resolutions, color models (RGB vs CMYK), fonts (sans-serif vs serif), and the need to hide interactive elements. Research by Nielsen Norman Group shows 70% of users complain about problems when printing from a browser. Our page printing CSS approach requires understanding the mechanics of page breaks, repeating table headers, headers and footers, and correct handling of backgrounds. We've tackled complex cases: from financial reports with dozens of tables to promo pages with branded colors. CSS page breaks are managed automatically, and typography for printing includes serif fonts for better readability.
How to Set Up Print CSS for Complex Tables?
Here is a step-by-step guide to setting up printing for a site with tables and multimedia using the print media query:
- Hide unnecessary interface elements: header, footer, nav, sidebar, banners, cookie notices, chat widgets. Creating a layout for printing starts here.
- Configure typography for paper: serif font, size 12pt, line height 1.5, display of link URLs. Our expertise in typography for printing ensures optimal readability on paper.
- Manage page breaks: forced break before chapters, avoid breaks inside tables and lists.
- Set up tables: repeat header on each page, forbid row breaks, style borders and backgrounds. For printing tables, we use display: table-header-group to repeat headers.
- Add headers/footers and page numbering via CSS @page. Configure print headers and footers with @page rules for page numbers and document title.
- Test in browsers and on a physical printer.
Basic Structure and Reset
First, hide everything not needed on paper: header, footer, nav, sidebar, banners, cookie notices, chat widgets. Stretch content to 100% width, remove shadows and rounded corners.
@media print {
header, footer, nav, aside, .sidebar, .cookie-banner,
.chat-widget, .share-buttons, .advertisement,
.back-to-top, [data-noprint], .no-print {
display: none !important;
}
.container, .wrapper, main, article {
width: 100% !important;
max-width: 100% !important;
margin: 0 !important;
padding: 0 !important;
float: none !important;
}
* {
box-shadow: none !important;
text-shadow: none !important;
border-radius: 0 !important;
}
}
Typography for Paper
Use serif fonts (Georgia, Times New Roman) with a base size of 12pt. Increase headings, set line spacing, add orphans and widows to control widow lines. Supplement links with URL display. For detailed understanding, see the documentation on Media queries.
@media print {
body {
font-family: Georgia, 'Times New Roman', serif;
font-size: 12pt;
line-height: 1.5;
color: #000;
background: #fff;
}
h1 { font-size: 24pt; margin-bottom: 12pt; }
h2 { font-size: 18pt; margin-bottom: 8pt; }
h3 { font-size: 14pt; margin-bottom: 6pt; }
p, li {
font-size: 12pt;
orphans: 3;
widows: 3;
}
a[href]:after {
content: ' (' attr(href) ')';
font-size: 10pt;
color: #555;
}
a[href^='#']:after,
a[href^='javascript:']:after {
content: '';
}
img {
max-width: 100% !important;
page-break-inside: avoid;
}
}
Managing Page Breaks and @page
Set forced breaks before chapters, avoid breaks inside tables and lists, control @page margins, and add headers and footers.
@media print {
h1, h2, h3, h4, h5, h6 {
page-break-after: avoid;
break-after: avoid;
}
.no-break, table, figure, blockquote {
page-break-inside: avoid;
break-inside: avoid;
}
.page-break-before, section.chapter {
page-break-before: always;
break-before: page;
}
.page-break-after {
page-break-after: always;
break-after: page;
}
}
@page {
size: A4 portrait;
margin: 2cm 2.5cm 2cm 2.5cm;
}
@page :first { margin-top: 3cm; }
@page :left { margin-left: 3cm; }
@page :right { margin-right: 3cm; }
@page {
@top-right {
content: 'Company LLC — Confidential';
font-size: 9pt;
color: #999;
}
@bottom-center {
content: 'Page ' counter(page) ' of ' counter(pages);
font-size: 9pt;
}
}
Tables: Headers on Every Page and Styling
To prevent large tables from turning into a mess, repeat the header on each sheet, forbid row breaks, and set printer-friendly colors.
@media print {
thead { display: table-header-group; }
tfoot { display: table-footer-group; }
tr { page-break-inside: avoid; }
table {
border-collapse: collapse;
width: 100%;
}
th, td {
border: 1px solid #999;
padding: 4pt 6pt;
text-align: left;
}
th {
background: #eee !important;
-webkit-print-color-adjust: exact;
print-color-adjust: exact;
}
}
Background Colors and JavaScript: Print Button and Events
For branded blocks use print-color-adjust: exact. Logos via ::before with an image, not via background-image. Add JS for a print button for a selected area and handlers beforeprint/afterprint to expand accordions and force lazy loading.
function printPage(selector?: string) {
if (selector) {
const content = document.querySelector(selector);
if (!content) return;
const printWindow = window.open('', '_blank');
if (!printWindow) return;
printWindow.document.write(`
<!DOCTYPE html>
<html>
<head>
<title>${document.title}</title>
<link rel="stylesheet" href="/css/app.css">
</head>
<body class="print-only">
${content.innerHTML}
</body>
</html>
`);
printWindow.document.close();
printWindow.focus();
printWindow.onload = () => {
printWindow.print();
printWindow.close();
};
return;
}
window.print();
}
document.querySelectorAll('[data-print-btn]').forEach(btn => {
const selector = btn.getAttribute('data-print-target');
btn.addEventListener('click', () => printPage(selector ?? undefined));
});
window.addEventListener('beforeprint', () => {
document.querySelectorAll('.accordion-content[hidden]').forEach(el => {
el.removeAttribute('hidden');
el.setAttribute('data-was-hidden', 'true');
});
document.querySelectorAll('img[loading="lazy"]').forEach(img => {
const image = img as HTMLImageElement;
if (image.dataset.src) image.src = image.dataset.src;
});
});
window.addEventListener('afterprint', () => {
document.querySelectorAll('[data-was-hidden]').forEach(el => {
el.setAttribute('hidden', '');
el.removeAttribute('data-was-hidden');
});
});
Typical Printing Problems and Their Solutions
| Problem | Solution |
|---|---|
| Interface elements (menus, banners) print out | Hide via display: none in print media query |
| Links appear as plain text | Add a[href]:after { content: ' (' attr(href) ')'; } |
| Tables break in the middle of a row | Set tr { page-break-inside: avoid; } and thead { display: table-header-group; } |
| Background colors/images don't print | Use print-color-adjust: exact and logos via img or ::before |
| Font too small | Set font-size: 12pt for body, at least 10pt for small elements |
Blank first page due to margin-top on body |
Use @page :first { margin-top: ...; } instead of margin on body |
For each problem we select an individual solution. For example, if background colors don't print, we use print-color-adjust: exact and check printer settings. If tables break, we add page-break-inside: avoid on rows. Handling such nuances requires experience — our engineer helps avoid 90% of typical errors.
What's Included in the Work
- Audit of current styles and identification of elements hindering printing
- Development of print CSS: reset, typography, breaks, tables, backgrounds
- Configuration of headers/footers, page numbering, and paper size
- Handling of @page rules, margin boxes, and named pages
- Custom JavaScript for advanced print triggers (selected area, before/after handlers)
- Testing in Chrome, Firefox, Edge, Safari; verification on a physical printer if needed
- Integration into your project (WordPress, Laravel, React, etc.)
- Documentation and comments in code
Timeline and Cost
| Phase | Estimated Timeline | Price |
|---|---|---|
| Basic print.css setup (landing page/blog) | from 2 hours | $150 |
| Complex page (tables, conditional visibility, branded colors) | from 1 day | $400 |
| Full audit and revision of existing project | from 4 hours | $250 |
Cost is calculated individually based on volume and complexity. Get a free consultation — we'll assess your project and offer the optimal solution.
Checklist Before Delivery
- [ ] Navigation, banners, widgets are hidden
- [ ] Link URLs are displayed (except anchors and javascript:)
- [ ] Tables are not broken mid-row
- [ ] Images do not exceed page margins
- [ ] No blank first pages
- [ ] Font is readable (at least 10pt)
- [ ] Headers/footers and page numbering work
- [ ] Background colors of branded blocks print correctly
Contact us to discuss your project. Order print CSS implementation — get perfect printing without hassle. Guaranteed results.
We've tested our print styles across 50+ sites, covering over 10,000 different pages.







