page-break-inside 42204o
The page-break-inside property is used to specify whether or not a page break should occur inside the element it is applied to. 5h4l2b
Page breaks are applied to paged media, such as printed books or documents. When a page is broken, the layout ends in the current page and the remaining elements of the document are laid out in a new page. You can see this in PDF documents, where some pages have a lot of white space left, and content continues on the next page. If no page break rules are specified, the page may break inside pieces of content such as text, lists, code snippets, images, etc.

Sometimes, the page breaks in the middle of an element such as an image, which causes it to be split and span across two pages. This is usually an undesirable effect.

You may want to avoid page breaks inside tables, code snippets, lists of items, and images, for example. Using the page-break-inside
property, you can do just that.
In the following example, we’re using the display to block
or inline-block
.
@media print { img { display: block; page-break-inside: avoid; } }
By doing this, the agent will print the entire image on a single page, either at the end of a page if there is enough space, or at the start of another one if there isn’t.
Similarly, you can avoid page breaks inside tables, lists, and any other block-level element.

page-break-inside
property.
Page breaks may help avoid or cause orphans and widows in pages.
When a page break splits a box, the box’s margins, borders, and padding have no visual effect where the split occurs.
Official Syntax 2f2j3w
- Syntax:
page-break-inside: avoid | auto | inherit
- Initial: auto
- Applies To: block-level elements in the normal flow of the root element. agents may also apply it to other elements like table-row elements.
- Animatable: no
Values 445h6m
- auto
- Neither force nor forbid a page break inside the element.
- avoid
- Avoid a page break inside the element.
Examples 5w70f
/* avoid page breaks in tables, lists, images, and code snippets */ @media print { img { display: block; } img, table, ul, ol, .code-snippet { page-break-inside: avoid; } }
Browser 51c73
CSS page-break properties 10642p
Properties to control the way elements are broken across (printed) pages.
W3C Recommendation
ed from the following versions:
Desktop 1qa5q
- 4
- 2
- 10
- 15
- 3.1
Mobile / Tablet 6x6t5m
- 3.2
- 2.1
- all
- 66
- 60