CSS page-break-before Property
The CSS page-break-before property controls whether a page break should occur immediately before an element when a document is printed.
It is a legacy CSS property retained for compatibility with older browsers and print engines. Modern CSS uses break-before to control page, column, and region breaks, but page-break-before remains useful in existing print stylesheets.
page-break-before Syntax
The page-break-before property accepts keywords that allow, discourage, or force a page break before an element.
Basic Syntax
selector {
page-break-before: always;
}
This requests a page break immediately before the selected element when the document is printed.
Available Values
.section {
page-break-before: auto;
}
.section {
page-break-before: always;
}
.section {
page-break-before: avoid;
}
.section {
page-break-before: left;
}
.section {
page-break-before: right;
}
The left and right values are intended for documents that distinguish left-hand and right-hand pages.
CSS-Wide Keywords
.section {
page-break-before: initial;
}
.section {
page-break-before: inherit;
}
.section {
page-break-before: unset;
}
.section {
page-break-before: revert;
}
.section {
page-break-before: revert-layer;
}
CSS-wide keywords must be used individually and cannot be combined with other values in the same declaration.
Property Values
| Value | Description |
|---|---|
auto |
Allows the browser to determine whether a page break is needed before the element. |
always |
Forces a page break before the element in paged media. |
avoid |
Requests that a page break not occur immediately before the element. |
left |
Forces a break so the element begins on a left-hand page. |
right |
Forces a break so the element begins on a right-hand page. |
initial |
Resets the property to its initial value of auto. |
inherit |
Uses the computed value from the parent element. |
unset |
Resets the property to auto because it is not inherited. |
revert |
Reverts the property according to CSS cascade origin rules. |
revert-layer |
Reverts the property according to CSS cascade layer rules. |
Property Characteristics
| Characteristic | Value |
|---|---|
| Initial value | auto |
| Inherited | No |
| Applies to | Block-level elements in normal flow within paged media |
| Computed value | As specified |
| Animation type | Discrete |
| Percentages | Not applicable |
| Primary use | Printed and paginated documents |
| Modern replacement | break-before |
| Status | Legacy compatibility property |
Valid Values
.chapter {
page-break-before: always;
}
.subheading {
page-break-before: avoid;
}
.section {
page-break-before: auto;
}
.appendix {
page-break-before: right;
}
Invalid Values
.section {
page-break-before: 20px;
}
.section {
page-break-before: 50%;
}
.section {
page-break-before: none;
}
.section {
page-break-before: page;
}
Lengths, percentages, none, and the modern page keyword are not valid values for page-break-before. Use break-before: page for the modern equivalent of page-break-before: always.
How It Works
When a browser prepares a document for printing, it divides the content into page-sized areas. The page-break-before property influences whether a page boundary may or must occur before an element.
Automatic Page Breaks
.section {
page-break-before: auto;
}
The browser can insert a page break when necessary to fit the document onto the available pages.
Forced Page Breaks
.chapter {
page-break-before: always;
}
The chapter begins on a new page, subject to the rules of paged layout and browser support.
Discouraging Page Breaks
.subheading {
page-break-before: avoid;
}
This requests that the browser avoid separating the subheading from the content immediately preceding it.
Page Breaks and Document Flow
A page break changes where content appears in the printed document. It does not remove content or change its order in the HTML source.
Important Limitation
Break avoidance is not an absolute guarantee. If content cannot fit within the available page area, the browser may need to break the document despite an avoidance request.
Forced Page Breaks
The always value is commonly used to begin chapters, appendices, and other major document sections on new pages.
Starting a Chapter on a New Page
.chapter {
page-break-before: always;
}
Each chapter using this rule requests a new page before its content.
Chapter Example
<section class="chapter">
<h2>Chapter One</h2>
<p>Chapter content goes here.</p>
</section>
<section class="chapter">
<h2>Chapter Two</h2>
<p>The second chapter starts on a new page.</p>
</section>
@media print {
.chapter {
page-break-before: always;
}
.chapter:first-child {
page-break-before: auto;
}
}
The first chapter follows normal pagination, while the second chapter requests a new page before its content.
Avoiding an Unnecessary First Break
@media print {
.print-section + .print-section {
page-break-before: always;
}
}
The adjacent sibling selector applies the break only to sections immediately following another section with the same class.
When to Use Forced Breaks
Forced page breaks are useful when a printed document requires clear divisions between major sections. Avoid adding them before every small content block because this can create unnecessary pages.
Left and Right Pages
The left and right values are designed for paged documents that distinguish left-hand and right-hand pages, such as books and manuals.
Starting on a Right-Hand Page
.chapter {
page-break-before: right;
}
The chapter is requested to begin on a right-hand page.
Starting on a Left-Hand Page
.appendix {
page-break-before: left;
}
The appendix is requested to begin on a left-hand page.
Blank Pages
In a two-sided paged layout, satisfying a left-hand or right-hand page request may require inserting a blank page.
Modern Equivalents
.chapter {
break-before: right;
}
.appendix {
break-before: left;
}
The modern break-before property supports these page-side values.
Browser Limitations
Not all browser print engines fully support left-hand and right-hand page selection. Some may treat these values similarly to a regular forced page break.
Avoiding Page Breaks
The avoid value requests that the browser avoid inserting a page break immediately before the selected element.
Keeping a Caption With Preceding Content
@media print {
figcaption {
page-break-before: avoid;
}
}
This discourages a page break between a figure and its caption when the caption follows the figure.
Keeping Related Paragraphs Together
@media print {
.continued-paragraph {
page-break-before: avoid;
}
}
This requests that a paragraph remain on the same page as the preceding content when possible.
Avoiding Breaks Inside Elements
@media print {
figure {
page-break-inside: avoid;
}
}
The separate page-break-inside property requests that an entire figure remain together on one page.
Combining Break Controls
@media print {
figcaption {
page-break-before: avoid;
}
figure {
page-break-inside: avoid;
}
}
These rules discourage breaks before captions and within figures, helping preserve related content.
Important Consideration
Browsers may override avoidance rules when necessary to paginate content. Avoidance works best with content that can reasonably fit on a single page.
Modern Alternative: break-before
The page-break-before property is deprecated in favor of break-before, which provides a broader fragmentation model.
Legacy Syntax
.chapter {
page-break-before: always;
}
Modern Syntax
.chapter {
break-before: page;
}
Both declarations request a page break before the element in paged media.
Value Comparison
| page-break-before | break-before |
|---|---|
auto |
auto |
always |
page |
avoid |
avoid-page |
left |
left |
right |
right |
The modern property also supports values for other fragmentation contexts, including multicolumn layouts.
Compatibility Pattern
@media print {
.chapter {
page-break-before: always;
break-before: page;
}
}
The legacy declaration provides compatibility with older print engines. The modern declaration follows it for browsers supporting break-before.
Avoiding Page Breaks With Modern CSS
@media print {
figcaption {
page-break-before: avoid;
break-before: avoid-page;
}
}
This requests that a caption remain with preceding content while supporting both legacy and modern syntax.
Important Distinction
The legacy always value maps to break-before: page for page-breaking behavior. The modern break-before: always value has broader fragmentation semantics and is not the direct compatibility equivalent.
Using page-break-before With Print Media
Page-break rules are generally placed inside an @media print block so they apply specifically to printed output.
Print-Specific Page Breaks
@media print {
.chapter {
page-break-before: always;
}
}
This keeps the page-break rule separate from the document's ordinary screen layout.
Combining With @page
@page {
size: A4;
margin: 20mm;
}
@media print {
.chapter {
page-break-before: always;
}
}
The @page rule requests page dimensions and margins, while page-break-before controls where new pages begin.
Screen and Print Styles
.chapter {
padding: 20px;
border: 1px solid #cbd5e1;
}
@media print {
.chapter {
padding: 0;
border: 0;
page-break-before: always;
}
}
The chapter retains its styled appearance on screen while using simplified formatting and page breaks when printed.
Print Preview
Use the browser's Print Preview feature to inspect page breaks before printing or saving the document as a PDF.
Printer and Browser Settings
Paper size, margins, scaling, and browser print behavior can affect pagination. Test the document using the intended print settings.
page-break-before Example
The following example demonstrates how to request a new printed page before each report section except the first.
HTML Example
<div class="print-report">
<section class="report-section">
<h2>Introduction</h2>
<p>This section introduces the report.</p>
</section>
<section class="report-section">
<h2>Project Details</h2>
<p>This section contains the project information.</p>
</section>
<section class="report-section">
<h2>Conclusion</h2>
<p>This section summarizes the report.</p>
</section>
</div>
CSS Example
.print-report {
display: grid;
gap: 15px;
}
.report-section {
padding: 20px;
border: 2px solid #2563eb;
background-color: #dbeafe;
}
.report-section h2 {
margin: 0 0 10px;
}
.report-section p {
margin: 0;
}
@media print {
.print-report {
display: block;
}
.report-section {
padding: 0;
border: 0;
background: transparent;
}
.report-section + .report-section {
page-break-before: always;
break-before: page;
}
}
Screen Preview
The following preview shows the report sections as they appear on screen. Page breaks are applied when printing and are not represented by the spaces between these boxes.
Introduction
This section introduces the report.
Project Details
This section contains the project information.
Conclusion
This section summarizes the report.
Expected Print Behavior
| Section | Requested Behavior |
|---|---|
| Introduction | Begins without an additional forced page break. |
| Project Details | Begins on a new page. |
| Conclusion | Begins on a new page. |
In a browser that honors these rules, each report section begins on a separate printed page. The exact output depends on the print engine and available page area.
Practical Chapter Example
@media print {
.chapter + .chapter {
page-break-before: always;
break-before: page;
}
.chapter h2 {
page-break-after: avoid;
break-after: avoid-page;
}
}
This starts subsequent chapters on new pages while requesting that chapter headings remain with their following content.
Accessibility Considerations
Page breaks affect the printed presentation of a document but do not change its semantic HTML structure.
Preserve Logical Reading Order
Keep content in a meaningful source order. Forced page breaks should separate related sections without making the document difficult to follow.
Keep Captions With Figures
@media print {
figure {
page-break-inside: avoid;
break-inside: avoid-page;
}
}
This requests that a figure and its caption remain together when possible.
Avoid Excessive Blank Pages
Use forced breaks only where they improve document organization. Unnecessary page breaks can make printed material harder to navigate.
Maintain Readable Print Layouts
Test the printed document for clipped text, separated captions, broken tables, and excessive whitespace.
Consider PDF Accessibility
Page breaks do not automatically create accessible PDF structure. Accessibility depends on the source document and the capabilities of the PDF generation process.
Important Consideration
Use semantic headings, meaningful document structure, and appropriate break controls together to create readable printed content.
Common Mistakes
Using the Modern page Value
.chapter {
page-break-before: page;
}
The page value belongs to the modern break-before property. Use page-break-before: always or break-before: page.
Using none Instead of auto
.section {
page-break-before: none;
}
The none keyword is invalid. Use auto to allow normal pagination.
Using Length or Percentage Values
.section {
page-break-before: 20px;
}
The property accepts page-break keywords, not spacing values.
Expecting Screen Layout Changes
Page breaks affect paged media. They do not create visible page boundaries in a normal scrolling webpage.
Applying Breaks Before Every Element
Forced breaks before small content blocks can create unnecessary pages and excessive whitespace.
Forgetting the First Section
The first section usually does not need a forced break before it. Use a selector that targets only subsequent sections when appropriate.
Assuming avoid Is Guaranteed
The browser may override break avoidance when content cannot fit within the available page area.
Ignoring Modern CSS
The legacy property remains useful for compatibility, but new print stylesheets should also consider break-before.
Confusing Break Before and Break After
page-break-before controls a break preceding an element. page-break-after controls a break following an element.
Important Considerations
Keep the following points in mind when using page-break-before:
- It controls page breaks before elements in paged media.
- It is a legacy property retained for compatibility.
- The modern replacement is
break-before. - Its initial value is
auto. - The property is not inherited.
- The
alwaysvalue forces a page break. - The
avoidvalue requests that a break not occur before the element. - The
leftvalue requests that the element begin on a left-hand page. - The
rightvalue requests that the element begin on a right-hand page. - Left-hand and right-hand page requests may require blank pages.
- Browser support for page-side selection varies.
- The
pagekeyword is not valid for the legacy property. - The
nonekeyword is invalid. - Lengths and percentages are not accepted.
- The modern equivalent of
page-break-before: alwaysisbreak-before: page. - Legacy and modern declarations can be combined for compatibility.
- Page-break rules are commonly placed inside
@media print. - The
@pageat-rule controls page dimensions and margins. - The
pageproperty assigns content to named page types. - Break avoidance is not guaranteed when content cannot fit.
- Forced breaks should be used sparingly to avoid unnecessary pages.
- The first section often does not need a forced break before it.
- Page breaks do not change the semantic structure of HTML.
- Print Preview should be used to verify the final pagination.
Browser Support
The CSS page-break-before property is Widely available in modern browsers, including Chrome, Edge, Firefox, and Safari. It has been supported for many years as part of CSS paged-media styling.
The property is deprecated in favor of break-before. Although legacy support remains broad, browsers may differ in their handling of forced breaks, avoidance rules, and left-hand or right-hand pages.
For current compatibility information, visit Can I Use? and search for page-break-before.
Specifications
The legacy page-break-before property originates from CSS Level 2 and is maintained through compatibility requirements in modern CSS fragmentation specifications.
CSS Fragmentation Module Level 3
The specification describes how legacy page-break properties map to modern fragmentation properties.
For additional documentation and examples, consult MDN Web Docs.
