page-break-before
Specifies the position of page breaks when printing.
Sample Code
div.test { page-break-before: auto;}
Available Values
| Value | Description |
|---|---|
| auto | Does not specify a page break position. This 'auto' is the initial value. |
| always | Forces a page break at the specified position. |
| avoid | Automatically adjusts to avoid a page break at the specified position. |
| left | Forces a page break at the specified position. When printing in two-page spread format, the specified element is printed on the left side. |
| right | Forces a page break at the specified position. When printing in two-page spread format, the specified element is printed on the right side. |
Browser Display Result
<p>Text. Text. Text. Text. Text. Text. Text. Text. Text.</p> <p style="page-break-before: auto;">This is a p element. 'page-break-before: auto' is specified here.</p> <p>Text. Text. Text. Text. Text. Text. Text. Text. Text.</p> <button onclick="window.print();" onmouseover="this.style.color = 'red';" onmouseout="this.style.color = 'black';">Print</button>
<p>Text. Text. Text. Text. Text. Text. Text. Text. Text.</p> <p style="page-break-before: always;">This is a p element. 'page-break-before: always' is specified here.</p> <p>Text. Text. Text. Text. Text. Text. Text. Text. Text.</p> <button onclick="window.print();" onmouseover="this.style.color = 'red';" onmouseout="this.style.color = 'black';">Print</button>
<p>Text. Text. Text. Text. Text. Text. Text. Text. Text.</p> <p style="page-break-before: avoid;">This is a p element. 'page-break-before: avoid' is specified here.</p> <p>Text. Text. Text. Text. Text. Text. Text. Text. Text.</p> <button onclick="window.print();" onmouseover="this.style.color = 'red';" onmouseout="this.style.color = 'black';">Print</button>
<p>Text. Text. Text. Text. Text. Text. Text. Text. Text.</p> <p style="page-break-before: left;">This is a p element. 'page-break-before: left' is specified here.</p> <p>Text. Text. Text. Text. Text. Text. Text. Text. Text.</p> <button onclick="window.print();" onmouseover="this.style.color = 'red';" onmouseout="this.style.color = 'black';">Print</button>
<p>Text. Text. Text. Text. Text. Text. Text. Text. Text.</p> <p style="page-break-before: right;">This is a p element. 'page-break-before: right' is specified here.</p> <p>Text. Text. Text. Text. Text. Text. Text. Text. Text.</p> <button onclick="window.print();" onmouseover="this.style.color = 'red';" onmouseout="this.style.color = 'black';">Print</button>
Browser Compatibility
Desktop
Supported in all versions
8 ○
7 ○
6 ○
6 and earlier ×Mobile
Android Browser
4.4+ ○
3 and earlier ×Same support as desktop
Same support as desktop
※ Version data is based on MDN.
Details
Specifies the position of page breaks when printing.
The page break occurs before the element to which this property is applied. To insert a page break after the element instead, use the 'page-break-after' property.
If you find any errors or copyright issues, please contact us.