CSS page-break-before Tutorial

CSS page-break-before

The page-break-before property in CSS is used to specify whether a page break should occur before an element when printing. This property can be applied to various elements, such as headings, paragraphs, divs, and more.

There are three possible values for the page-break-before property:

Let's see some examples of how the page-break-before property works:

Result:

    
This content will always start on a new page.

In this example, the page-break-before: always; property is applied to a div element, which means that the content will always start on a new page when printing.

Result:

    

This heading will not start on a new page.

Here, the page-break-before: avoid; property is applied to an h2 element, which prevents a page break before the heading when printing.

Experiment with different elements and values for the page-break-before property to control page breaks in your printed documents.