Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > Amazon Kindle

Notices

Reply
 
Thread Tools Search this Thread
Old 06-16-2020, 10:05 PM   #1
scruffs
Connoisseur
scruffs doesn't litterscruffs doesn't litter
 
Posts: 59
Karma: 100
Join Date: Jun 2020
Device: ePUB Kindle and iBooks
Exclamation page-break-after avoid not working

I have this set up in CSS. All headings are display:block

I simply cannot get page-break-after:avoid working.

I have H1 with a break before. Fine.
I also have H2 with a break before (necessary for the content type).

But I want H3... to NOT break after. But I still keep getting H3, H4, etc. at the bottom of the page. I want them to appear on the same page as the text.

Even the Amazon docs says this should work. But I tried it with a minimal test file and it still doesn't.

Any ideas?

Thanks, chaps.
scruffs is offline   Reply With Quote
Old 06-16-2020, 10:26 PM   #2
jhowell
Grand Sorcerer
jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.
 
jhowell's Avatar
 
Posts: 5,816
Karma: 66686873
Join Date: Nov 2011
Location: Tampa Bay, Florida
Device: Oasis 2, iPad, Nexus 7
You mention Amazon. Are you referring to the Kindle platform? If so how are you testing it.

Support for page-break-after:avoid is a recent addition to Kindles and only works in KFX format (enhanced typesetting.)
jhowell is online now   Reply With Quote
Advert
Old 06-16-2020, 11:38 PM   #3
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 26,121
Karma: 181362750
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
And the value is "avoid" for a reason. It's because "never" cannot be guaranteed. It's support has always been famously hit-or-miss in epubs.
DiapDealer is online now   Reply With Quote
Old 06-17-2020, 03:28 AM   #4
scruffs
Connoisseur
scruffs doesn't litterscruffs doesn't litter
 
Posts: 59
Karma: 100
Join Date: Jun 2020
Device: ePUB Kindle and iBooks
Yeas, I meant to say Kindle. I am testing in Kindle Previewer and the Calibre viewer (also in iBooks). Nada,

I know 'avoid' can never be guaranteed (not sure I understand the rationale, though) but it does not seem to work on any of them.

Should it work?

Cheers
scruffs is offline   Reply With Quote
Old 06-17-2020, 04:54 AM   #5
jhowell
Grand Sorcerer
jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.
 
jhowell's Avatar
 
Posts: 5,816
Karma: 66686873
Join Date: Nov 2011
Location: Tampa Bay, Florida
Device: Oasis 2, iPad, Nexus 7
Quote:
Originally Posted by scruffs View Post
I know 'avoid' can never be guaranteed (not sure I understand the rationale, though) but it does not seem to work on any of them.

Should it work?
It should be honored in most cases in the Kindle Previewer as long as your book has the green "enhanced typesetting" check mark shown.
jhowell is online now   Reply With Quote
Advert
Old 06-17-2020, 05:12 AM   #6
scruffs
Connoisseur
scruffs doesn't litterscruffs doesn't litter
 
Posts: 59
Karma: 100
Join Date: Jun 2020
Device: ePUB Kindle and iBooks
I'm stumped.

I now stripped out every page-break- reference in CSS. So, to test, I just have
page-break-after: avoid !important;
set for H3

But I am still getting H3 on a single line at the bottom of the page. Looks awful.
scruffs is offline   Reply With Quote
Old 06-17-2020, 01:48 PM   #7
hobnail
Running with scissors
hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.
 
Posts: 1,541
Karma: 14325062
Join Date: Nov 2019
Device: none
That would certainly drive me nuts. If I couldn't get it to work I'd toss in the towel and force a page break before the h3 tag.

For the sake of consistency I wrap all of my h? tags in header tags. This may not (or probably) won't help but what if you did that and in your css had something like mine,
Code:
header {
    display: block;
    margin-top: 2em;
    margin-bottom: 5em;
    page-break-after: avoid;
    page-break-inside: avoid;
}

Last edited by hobnail; 06-17-2020 at 02:58 PM.
hobnail is offline   Reply With Quote
Old 06-17-2020, 02:19 PM   #8
jhowell
Grand Sorcerer
jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.
 
jhowell's Avatar
 
Posts: 5,816
Karma: 66686873
Join Date: Nov 2011
Location: Tampa Bay, Florida
Device: Oasis 2, iPad, Nexus 7
Quote:
Originally Posted by scruffs View Post
But I am still getting H3 on a single line at the bottom of the page. Looks awful.
I suggest that you produce a short sample book that demonstrates the problem and post it here as an attachment. That will allow others to take a look at it and see what might be causing the problem.
jhowell is online now   Reply With Quote
Old 06-17-2020, 03:52 PM   #9
scruffs
Connoisseur
scruffs doesn't litterscruffs doesn't litter
 
Posts: 59
Karma: 100
Join Date: Jun 2020
Device: ePUB Kindle and iBooks
Thanks!

I've set up something very simple. epub attached.

I then opened in Calibre epub viewer. I get the rogue heading again. I've attached a screenshot of it.

Thanks for your help.
Attached Thumbnails
Click image for larger version

Name:	Test 01 Screenshot 2020-06-17 at 19.48.15.png
Views:	156
Size:	555.9 KB
ID:	179962  
Attached Files
File Type: epub Test 01.epub (6.8 KB, 157 views)
scruffs is offline   Reply With Quote
Old 06-17-2020, 04:30 PM   #10
jhowell
Grand Sorcerer
jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.
 
jhowell's Avatar
 
Posts: 5,816
Karma: 66686873
Join Date: Nov 2011
Location: Tampa Bay, Florida
Device: Oasis 2, iPad, Nexus 7
Quote:
Originally Posted by scruffs View Post
I've set up something very simple. epub attached.
I tried your book in Kindle Previewer version 3.40 and I was not able to force a break between a heading and the following text at any of the device/font/size/orientation combinations that I tried. As far as I can tell it is working properly there.

Quote:
Originally Posted by scruffs View Post
I then opened in Calibre epub viewer. I get the rogue heading again. I've attached a screenshot of it.
I agree that the calibre viewer does not appear to be obeying the page-break-after:avoid style.
jhowell is online now   Reply With Quote
Old 06-18-2020, 04:28 AM   #11
scruffs
Connoisseur
scruffs doesn't litterscruffs doesn't litter
 
Posts: 59
Karma: 100
Join Date: Jun 2020
Device: ePUB Kindle and iBooks
Thanks for that.

But I most certainly get the problem on the book I have actually written. Screenshot attached. H4 is shown at the bottom of the page

I guess the first thing is to eliminate the CSS as the culprit. I have validated it with no errors. But of course, there may be some other conflicts that I am not expert enough to pick up on.

So Ive attached the CSS as well. If you wouldn't mind taking a squint at it, I'd be very grateful.

Cheers,
Colin
Attached Thumbnails
Click image for larger version

Name:	Screenshot 2020-06-18 at 08.26.24.png
Views:	149
Size:	148.5 KB
ID:	179969  
Attached Files
File Type: txt temp-css 2.txt (7.5 KB, 122 views)
scruffs is offline   Reply With Quote
Old 06-18-2020, 07:41 PM   #12
jhowell
Grand Sorcerer
jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.
 
jhowell's Avatar
 
Posts: 5,816
Karma: 66686873
Join Date: Nov 2011
Location: Tampa Bay, Florida
Device: Oasis 2, iPad, Nexus 7
Quote:
Originally Posted by scruffs View Post
So Ive attached the CSS as well. If you wouldn't mind taking a squint at it, I'd be very grateful.
I tried your "temp-css 2" style sheet with your previously posted "Test 01" EPUB file and was able to duplicate the ignoring of "page-break-after: avoid" using the Kindle Previewer.

With a bit of trial and error I was able to fix the problem by eliminating the property "background-color: #FFF" from the style sheet.

Looking at the proprietary Amazon ION code produced by the Kindle Previewer I was able to determine that the presence of this property causes the Kindle Previewer to insert a new block level element at the highest level of the document. That prevents the page-break handling from being effective since the KFX renderer only honors it when it is used in conjunction with a top level element.

The Enhanced Typesetting (KFX) conversion process definitely has some quirks!
jhowell is online now   Reply With Quote
Old 06-18-2020, 07:45 PM   #13
scruffs
Connoisseur
scruffs doesn't litterscruffs doesn't litter
 
Posts: 59
Karma: 100
Join Date: Jun 2020
Device: ePUB Kindle and iBooks
Oh, good grief. You are an absolute rockstar.

I have several references to background-color: FFF for various elements. So I shall give it a try and post back so we can hopefully close this one.

I cannot thank you enough for your time and effort. Cheers.
scruffs is offline   Reply With Quote
Old 06-18-2020, 11:09 PM   #14
hobnail
Running with scissors
hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.
 
Posts: 1,541
Karma: 14325062
Join Date: Nov 2019
Device: none
Quote:
Originally Posted by scruffs View Post
Oh, good grief. You are an absolute rockstar.

I have several references to background-color: FFF for various elements. So I shall give it a try and post back so we can hopefully close this one.

I cannot thank you enough for your time and effort. Cheers.
Not a good idea to use that background-color since some ereaders allow a night mode which is white text on a black background. When you set the background like that they'll get white text on a white background.
hobnail is offline   Reply With Quote
Old 06-19-2020, 03:22 AM   #15
scruffs
Connoisseur
scruffs doesn't litterscruffs doesn't litter
 
Posts: 59
Karma: 100
Join Date: Jun 2020
Device: ePUB Kindle and iBooks
Hey hobnail.

Yep. That was my 'dog' moment!

I think I can still keep it for images and tables, etc., but not for the html tag.

Thanks, old chap.
scruffs is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
page-break-after:avoid on iBooks Oxford-eBooks Apple Devices 1 08-12-2013 12:40 PM
Page-Break-Inside: Avoid - Solution or Hack? sab1234 Kindle Formats 3 01-17-2013 05:10 PM
page-break...:avoid / captions Oxford-eBooks Kindle Formats 6 10-05-2012 07:15 AM
Page-break-inside:avoid and mobi AlexBell Kindle Formats 3 06-01-2011 07:03 AM
How to avoid page break after heading/chapter tkirke ePub 6 01-22-2010 03:12 PM


All times are GMT -4. The time now is 09:08 AM.


MobileRead.com is a privately owned, operated and funded community.