For the complete documentation index, see llms.txt. This page is also available as Markdown.

How To: Create Multi-Page Documents with Page Breaks

Control page breaks and keep content together in multi-page documents.

Use page break styling when document sections must start or stay together on specific pages.

Problem

You need to control where page breaks occur in your generated documents.

Solution 1: CSS Page Break

Force a page break after a section:

<div style="page-break-after: always;">
  <h1>Page 1 Content</h1>
  <p>This content appears on page 1.</p>
</div>

<div>
  <h1>Page 2 Content</h1>
  <p>This content appears on page 2.</p>
</div>

Avoid a page break inside an element:

<div style="page-break-inside: avoid;">
  <h2>Keep Together</h2>
  <p>This entire section stays on one page.</p>
  <ul>
    <li>Item 1</li>
    <li>Item 2</li>
  </ul>
</div>

Solution 2: Table Row Page Breaks

Keep table rows together:

Solution 3: Conditional Page Breaks

Break before certain categories:

Tips

  • page-break-after: always forces a break after the element.

  • page-break-before: always forces a break before the element.

  • page-break-inside: avoid keeps the element together.

  • This works best in PDF output.

  • Test with real content lengths before release.

Last updated

Was this helpful?