Use CSS pagination rules in a stylesheet Dompdf loads: set page-break-before: always or page-break-after: always for deliberate boundaries, and page-break-inside: avoid when you want a supported block kept together. The first two force a break at a boundary; the last is a preference, not a guarantee. Tables need extra care: Dompdf does not split table rows across pages, and its support for break rules differs between rows and row groups.
Choose the rule that matches the boundary
Dompdf is a PHP HTML-to-PDF renderer. It supports most CSS 2.1 and selected CSS3 features, including @media and @page, but the exact behavior of pagination depends on the installed Dompdf version and the structure of the HTML. The three page-break properties are supported generally, subject to documented table-related limitations.
| Goal | CSS rule | What it asks Dompdf to do |
|---|---|---|
| Start a block on a fresh page | page-break-before: always |
Force a break before that block. |
| End a block with a page boundary | page-break-after: always |
Force a break after that block. |
| Keep a block together if it can fit | page-break-inside: avoid |
Avoid a break inside the block where possible; it cannot promise that content taller than a page will stay intact. |
Apply forced breaks to intentional structural boundaries, such as the start of a chapter or a new report section. Use an inside-avoid rule selectively for content that should remain together, such as a compact card or heading-and-summary block. Do not use an avoid rule as a substitute for checking whether the content can physically fit in the printable area.
Set up reusable page-break classes
Put the pagination rules in the stylesheet Dompdf receives with the HTML. This reusable pattern starts each section after the first on a new page while allowing the opening section to begin normally:
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minute#1 Best Overall
- INNOVATIVE CARTRIDGE-FREE PRINTING — No more dealing with lots of tiny ink cartridges; With this wireless document and photo printer each ink bottle set is equivalent to about 90 individual cartridges²
- LESS FREQUENT INK REPLACEMENT — Replacement ink bottles don't have to be changed nearly as often as ink cartridges¹; When you choose this combination printer, scanner and copier you can print up to 4,500 pages black/7,500 color³
- COLOR PRINTING — Up to 2 years of ink in the box4 (and with every replacement ink set) for fewer out-of-ink frustrations
- ZERO CARTRIDGE WASTE — By using an Epson EcoTank printer you can help reduce the amount of cartridge waste ending up in landfills
- HOME PRINTER DESIGNED FOR RELIABILITY — The Epson EcoTank ET-2800 All-in-One Supertank Color Printer creates vivid, detailed prints and documents thanks to Micro Piezo Heat-Free Technology; Fire off 10 ISO pages per minute1 to easily finish large jobs
<style>
.section {
page-break-before: always;
}
.section:first-of-type {
page-break-before: auto;
}
.keep-together {
page-break-inside: avoid;
}
</style>
<section class="section">
<h1>Opening section</h1>
<p>This begins without an extra forced page.</p>
</section>
<section class="section">
<h1>Next section</h1>
<p>This section starts on a new page.</p>
</section>
<div class="keep-together">
<h2>A compact block</h2>
<p>Ask Dompdf to keep this block together when it can.</p>
</div>
The :first-of-type override matters when the first content section shares the class that forces page starts. Without an override, the first section may also receive a forced break, producing an unwanted blank opening page. The exact selector should match the structure of your HTML: :first-of-type means the first element of that tag type among its siblings, not necessarily the first element with the class in the entire document.
If the boundary belongs after a block instead, use page-break-after: always. For example, a chapter-ending block could use a class with that declaration. Avoid forcing a break both after one block and before the next unless you have verified the result; both rules express a forced boundary at the same transition and can make the stylesheet harder to reason about.
Understand forced breaks and avoid rules together
CSS paged-media semantics distinguish three useful values: auto neither forces nor forbids a break, always forces a break, and avoid asks the renderer to avoid one. A potential break is affected by the inside-break setting on a parent and by the after value on preceding content and before value on following content. Where a forced value meets an avoid preference, the forced break takes precedence.
Rank #2
- CARTRIDGE-FREE PRINTING — Print lab-quality photos, graphics and creative projects; Get vibrant colors and sharp text with Epson's high-accuracy printhead and Claria ET Premium 6-color inks
- INK BOTTLES — Save on photos1 and creative projects with affordable in-house printing; All-in-one printer allows you to print 4" x 6" photos for about 4 cents each vs. 40 cents with traditional ink cartridges1
- LESS FREQUENT INK REPLACEMENT — Replacement ink bottles don't have to be changed nearly as often as ink cartridges¹; Printer, scanner and copier lets you print up to 6,200 color pages³
- PRINT FOR LONGER — Up to 2 years of ink in the box² (and with every replacement ink set) for fewer out-of-ink frustrations with this wireless printer
- ZERO CARTRIDGE WASTE — Epson EcoTank printer helps reduce the amount of cartridge waste ending up in landfills; Cartridge-free printer uses high-yield ink bottles; Each replacement ink bottle set is equivalent to about 100 individual ink cartridges⁴
An avoid rule cannot make an impossible layout possible. When the content overflows and there are not enough available break opportunities, avoidance rules may be relaxed so the renderer can place the remaining content. In practice, a tall block may still break, overflow, or produce an unsatisfactory layout even though it has page-break-inside: avoid. Treat the property as a layout preference and inspect the PDF rather than assuming it guarantees indivisibility.
The standards describe break-selection principles but do not prescribe one uniquely correct break for every document. Dompdf version, element type, surrounding rules, and the amount of content all matter. A rule that works for an ordinary block should not be assumed to work identically on a table row or row group.
Handle tables as a special case
Dompdf documents a key constraint: “Table cells are not pageable, meaning a table row must fit on a single page.” That means a page-break declaration cannot make an over-height row split neatly across pages. If a row is taller than the available page area, revise its content or structure rather than relying on pagination CSS to divide it.
Rank #3
- SET IT UP ONCE AND PRINT WITH CONFIDENCE. No complicated maintenance. Just easy, reliable printing you can count on.
- INK FOR YEARS. NOT MONTHS. Up to 2 years of ink included. Get thousands of pages of cartridge-free printing. More pages, less hassle
- KEEPS PRINTING WELL AFTER COMPETITORS HAVE QUIT. No complex maintenance. Sharper text, richer colors.[2] Only with HP Smart Tank
- PREMIUM SUPPORT - Strong technical expertise to solve issues faster
- THE LAST PRINTER YOU'LL EVER NEED. Enjoy years of refillable, cartridge-free printing.
| Element | Documented support detail | Practical implication |
|---|---|---|
| Ordinary block | The page-break properties are supported generally. | Use the before/after properties for deliberate boundaries and inside-avoid as a preference. |
Table row (tr) |
page-break-before and page-break-after are supported on rows since Dompdf 1.1.0; table cells are not pageable. |
Check the installed version. A row still needs to fit on one page. |
Table row group (thead, tbody, or tfoot) |
The compatibility reference marks before, after, and inside handling on row groups as unsupported. | Do not count on a group-level declaration behaving like the same declaration on a block or supported row. |
For long tables, test representative markup rather than extrapolating from a short sample. Include rows close to the available page height, a row that would exceed it, and any row-level or group-level rules the production document uses. A table’s row and its enclosing row group are different targets for CSS support.
Verify behavior in the Dompdf version you deploy
Check the version installed in your application and compare its behavior with the project’s compatibility notes. Dompdf cautions that its master-branch README may describe code newer than the latest release, and the compatibility reference includes version-specific details. Do not treat a rule’s general support listing as proof that every target element behaves the same way in your deployed version.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →- Identify the Dompdf package version used by the application that generates the PDF.
- Apply pagination rules to the actual HTML elements that represent your boundaries.
- Render a representative document, including first-page content, section transitions, and table rows near page height.
- Open the generated PDF and check for blank pages, unexpected splits, stranded headings, and rows that do not fit.
- Adjust the markup or rule placement, then render again. Keep the representative case as a regression check when changing the template or Dompdf version.
This verification is especially important when content length varies. A short sample may fit naturally and conceal a rule interaction that appears only in a full report.
Rank #4
- Wireless Bluetooth Printer: Portable thermal printer compatible with iPhone, Android phones, iPad and tablet computers via Bluetooth. For smartphones, please download the "Nada Print" App. You can also connect to laptops and computers for printing using a USB-C cable. (Note: Laptops and computers can only be connected via USB and require the installation of a driver first. Bluetooth connection is not supported.)
- No-ink printing: Only supports US Letter and A4 size thermal paper.(Doesn't support regular paper) The no-ink portable thermal printer uses direct thermal technology, requiring no ink, toner or ribbons, making it environmentally friendly, cost-effective and time-saving. The thermal printer package comes with a roll of US Letter thermal printing paper. Note: When installing the paper, remember to switch the paper size switch on APP
- Clear Print: NDYIN N80 portable thermal printer adopts high-definition printing technology, with a 203DPI resolution to provide you with clear printing results. This mobile printer is compatible with roll paper, folded paper and tattoo transfer paper, supporting printing from your mobile phone PDF, Word, pictures and web pages anytime and anywhere. It is recommended to use our NDYIN thermal paper to achieve good printing quality
- Portable wireless printer for travel: The thermal printer is equipped with a built-in 1500mAh rechargeable battery, which can print 160 sheets of 8.5" x 11" thermal paper after being fully charged. It weighs only 1.5 pounds and is compact in size. This ink-free portable printer can be easily carried in a backpack or briefcase! It is perfect for business travel, cars, small offices, construction sites, schools and homes. You can print documents, contracts, invoices and boarding passes anytime and anywhere
- The N80 thermal printer has a wide range of uses. The package includes the N80 printer, a roll of US Letter paper(7m/roll), a user manual, a guide card, a type-C soft cable and a type C adapter. Note: The charging adapter is not included. Special thermal paper is required for use; ordinary paper cannot be used. This ink-free portable thermal printer is suitable for various scenarios such as home, school, travel, office, and outdoor, meeting the printing needs of different groups of people. This tattoo template printer is also compatible with tattoo transfer paper, making it an ideal choice for tattoo art
Profile large tables instead of adding avoid rules everywhere
A June 2026 report on Dompdf issue #3738 describes roughly 500 table rows taking roughly 30 seconds in that report’s environment: Dompdf 3.1.5 and PHP 8.3.29, with page-break-inside: avoid applied to each row. The report attributes the cost to table reflow and page-break handling. It is one issue investigation, not an independently validated benchmark or a prediction for all documents.
The useful takeaway is narrow: for a very large table, avoid adding per-row keep-together rules without a reason, and profile the workload you actually generate. Do not infer a general speed penalty or a fixed processing time from that report. The amount and shape of the content, the renderer version, and the template all differ between applications.
Troubleshoot common page-break problems
- An unexpected blank first page: Check whether the first section also has
page-break-before: always. Override that first section toauto, as in the example, or apply the forced-break class only to later sections. - A keep-together block still splits: Confirm the rule applies to a supported element and that the block can fit in the available page area. Avoid is not an absolute guarantee when content overflows.
- A table row will not split across pages: This is a documented Dompdf limitation. Each row must fit on a single page; shorten or restructure an over-height row.
- A rule on
tbody,thead, ortfoothas no effect: Row-group handling for the page-break properties is listed as unsupported. Target a supported structure and verify it with the installed version. - A row-level before/after rule behaves differently on an older installation: The compatibility table records row support for those properties since version 1.1.0. Check the deployed version rather than assuming support based on current documentation.
- PDF generation becomes slow after adding avoid rules to every row: Remove unnecessary rules and profile the real document. The reported June 2026 issue is a scoped example, not a universal performance result.
- A break occurs despite a reasonable-looking stylesheet: Inspect the resulting PDF and the actual element structure. Parent inside rules and neighboring before/after rules can interact, and renderer behavior depends on version and available break points.
Or skip the browser setup
Dompdf remains the method for controlling pagination in a generated PDF. ScreenshotNeo is a separate website screenshot API, not a Dompdf pagination engine; it can help when you need a screenshot of a rendered web page, but it does not replace the CSS rules above or generate this Dompdf layout.
For a webpage screenshot, one GET request returns an image or PDF. Replace the target URL as needed:
Quick Recap
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options. It removes cookie and consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are not billed. Its MCP server lets AI agents use screenshot tools, and the free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Learn more at ScreenshotNeo, or sign up for the free plan.
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.




