> For the complete documentation index, see [llms.txt](https://help.sdocs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.sdocs.com/sdocs/advanced-template-logic/template-attributes/template-attributes-how-to-guides/how-to-create-multi-page-documents-with-page-breaks.md).

# 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:**

```
<style>
  tr {
    page-break-inside: avoid;
  }
</style>

<table>
<!--{{!
<lineitems>
<listname>opportunitylineitems</listname>
<column>PricebookEntry.Product2.name</column>
<column>Description</column>
</lineitems>
}}-->
</table>
```

### Solution 3: Conditional Page Breaks

**Break before certain categories:**

```
<!--{{!
<lineitemsSOQL>
<soql>SELECT Name, Category__c FROM Product2 WHERE Id IN (SELECT Product2Id FROM OpportunityLineItem WHERE OpportunityId = '{{!Opportunity.Id}}')</soql>
<column type="rtf" render="RECORD.Category__c == 'Services',lt#div style='page-break-before: always;'gt#lt#h2gt#Services Productslt#/h2gt#lt#/divgt#RECORD.Name,RECORD.Name"></column>
</lineitemsSOQL>
}}-->
```

### 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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.sdocs.com/sdocs/advanced-template-logic/template-attributes/template-attributes-how-to-guides/how-to-create-multi-page-documents-with-page-breaks.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
