![]() |
#1 |
Connoisseur
![]() ![]() Posts: 59
Karma: 100
Join Date: Jun 2020
Device: ePUB Kindle and iBooks
|
![]()
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. |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,013
Karma: 89771379
Join Date: Nov 2011
Location: Charlottesville, VA
Device: Kindles
|
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.) |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,341
Karma: 203719646
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.
|
![]() |
![]() |
![]() |
#4 |
Connoisseur
![]() ![]() 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 |
![]() |
![]() |
![]() |
#5 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,013
Karma: 89771379
Join Date: Nov 2011
Location: Charlottesville, VA
Device: Kindles
|
It should be honored in most cases in the Kindle Previewer as long as your book has the green "enhanced typesetting" check mark shown.
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Connoisseur
![]() ![]() 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. |
![]() |
![]() |
![]() |
#7 |
Running with scissors
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,581
Karma: 14328510
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 01:58 PM. |
![]() |
![]() |
![]() |
#8 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,013
Karma: 89771379
Join Date: Nov 2011
Location: Charlottesville, VA
Device: Kindles
|
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.
|
![]() |
![]() |
![]() |
#9 |
Connoisseur
![]() ![]() 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. |
![]() |
![]() |
![]() |
#10 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,013
Karma: 89771379
Join Date: Nov 2011
Location: Charlottesville, VA
Device: Kindles
|
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.
I agree that the calibre viewer does not appear to be obeying the page-break-after:avoid style. |
![]() |
![]() |
![]() |
#11 |
Connoisseur
![]() ![]() 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 |
![]() |
![]() |
![]() |
#12 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,013
Karma: 89771379
Join Date: Nov 2011
Location: Charlottesville, VA
Device: Kindles
|
Quote:
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! |
|
![]() |
![]() |
![]() |
#13 |
Connoisseur
![]() ![]() 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. |
![]() |
![]() |
![]() |
#14 |
Running with scissors
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,581
Karma: 14328510
Join Date: Nov 2019
Device: none
|
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.
|
![]() |
![]() |
![]() |
#15 |
Connoisseur
![]() ![]() 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. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
page-break-after:avoid on iBooks | Oxford-eBooks | Apple Devices | 1 | 08-12-2013 11:40 AM |
Page-Break-Inside: Avoid - Solution or Hack? | sab1234 | Kindle Formats | 3 | 01-17-2013 04:10 PM |
page-break...:avoid / captions | Oxford-eBooks | Kindle Formats | 6 | 10-05-2012 06:15 AM |
Page-break-inside:avoid and mobi | AlexBell | Kindle Formats | 3 | 06-01-2011 06:03 AM |
How to avoid page break after heading/chapter | tkirke | ePub | 6 | 01-22-2010 02:12 PM |