Sorry that you are struggling with this.
@media print {
img { page-break-inside:avoid; }
text { page-break-inside:avoid; }
}
Is CSS so it is not specific to WordPress or Elementor but the way websites work in general with HTML.
The issue you have is text is not an HTML element so will not be recognized.
You need to use valid HTML e.g. p for paragraph
@media print {
img { page-break-inside:avoid; }
p { page-break-inside:avoid; }
}
see https://codex.wordpress.org/Styling_for_Print#Page_Breaks for more examples
-
This reply was modified 5 years, 3 months ago by
fullworks.
-
This reply was modified 5 years, 3 months ago by
fullworks.
-
This reply was modified 5 years, 3 months ago by
fullworks.
Joy
(@joyously)
This is not a design flaw in WordPress, since WordPress isn’t responsible for the output on the front end. The theme is responsible for that, and it should have print styles. But a lot of themes do not bother.
The last several default themes have print styles, because I advocated for them, although they might not all handle everything. You can read the print stylesheets for those Twenty* themes to see what is in them, and add it to your Custom CSS.
Thanks for these suggestions. I tried the code “p { page-break-inside:avoid; }” but unfortunately it didn’t work. I also tried “pre” for good measure. I’m looking into the second comment right now.
You need to examine the html that is being split and then use the right selector.
Thanks. The html class of the text is either p, div, or span. I’ve tried all of these, one by one and together, and unfortunately none of them work. Sometimes these put large gaps into the printed pages, but they are still splitting individual lines of text.
I found the print stylesheet for the newest WordPress theme, and it uses the same method. I also tried setting the page margins within the print css, but that also didn’t work.
Joy
(@joyously)
Those print styles don’t dictate no breaks, only that the breaks should be avoided if possible. Obviously, you can’t avoid a break of something that is longer than a page. And to try to put that on span tags is kinda crazy. It is usually for block elements such as tables and images.
Perhaps the problem is on Elementor’s side, so I’ll see what I can find out through them. Honestly, this is a ridiculous problem. There is a design flaw somewhere.