Page-break-inside:avoid not working

Katie Fritz picture Katie Fritz · Dec 30, 2015 · Viewed 15.3k times · Source

I have a print stylesheet for my (Wordpress) site, and I want images to print on a single page rather than being split across pages. In some cases, even lines of text are being split across pages. I've included img {page-break: avoid;) in my print stylesheet, but no luck. I've found some previous answers but they're kind of old.

Is there a reliable way to print a moderately-sized image on a single page rather than splitting it across pages? Why are lines of text breaking across pages?

picture broken across two pages

lines breaking across pages

Site: http://74.220.217.211/housing-developments/grafton-townhomes/

Related posts:

Answer

Kristjan Retter picture Kristjan Retter · Jan 22, 2020

It could be that the parent element of the img element has style:

display: flex

Then the break-inside doesn’t work.

For example if you change parent element display style to:

display: block

Then it will work.