Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 07-24-2025, 04:20 PM   #1
PilcrowandStanza
Member
PilcrowandStanza began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Dec 2023
Device: none
keep header with following text

Hi all,

There has to be a simple fix for this, right?
Titles/headers at the bottom of the page with the text starting on the next.

How to keep them together! I use CSS "page break: avoid" to little luck.
Is there extra code that needs to be added?

Or do we simply accept that ebooks are wonky?

Thanks
PilcrowandStanza is offline   Reply With Quote
Old 07-24-2025, 05:26 PM   #2
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,779
Karma: 6000000
Join Date: Nov 2009
Device: many
In epubs, you typically start each chapter in its own new file. Each file automatically starts on a new page so chapter title and headings all work. That still leaves subheadings. For sub headings, can wrap them in a div and set css widows and orphans properties for that block. You can also try setting css pagebreak options before. For graphics you can try figure and figcaption to keep them together or float text around them.
KevinH is offline   Reply With Quote
Old 07-24-2025, 09:03 PM   #3
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,784
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by PilcrowandStanza View Post
Hi all,

There has to be a simple fix for this, right?
Titles/headers at the bottom of the page with the text starting on the next.

How to keep them together! I use CSS "page break: avoid" to little luck.
Is there extra code that needs to be added?

Or do we simply accept that ebooks are wonky?

Thanks
Employ the following style:

1. In your .css stylesheet:

Code:
.noBreakAfter {
    -webkit-column-break-after: avoid; /* This is for epub3, epub2 ebooks will ignore it */
    page-break-after: avoid; /* This is for epub2; epub3 ebooks will ignore it */
    break-after: avoid; /* Also for epub3 */
}
2. In your .xhtml:

Code:
<h2 class="noBreakAfter">Your title here</h2>

<p>Your following text here ... </p>
Of course, if you don't want to create a style, you also can write the following in your .css:

Code:
h1, h2, h3, h4, h5, h6 {
    -webkit-column-break-after: avoid;
    page-break-after: avoid;
    break-after: avoid;
}
EDIT: Which e-reader are you going to use this feature on?

Last edited by RbnJrg; 07-24-2025 at 09:32 PM.
RbnJrg is offline   Reply With Quote
Old 07-24-2025, 09:51 PM   #4
Quoth
Still reading
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 14,106
Karma: 105211945
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
Only starting a new file at a header works on everything.

Yes, real reflowable ebook formats are more limited than paper or PDF due to the combination of unknown screen size/resolution, user selected font size, user selected margins and line spacing and pagination rather than stupid endless scroll of web pages.
Quoth is offline   Reply With Quote
Old Yesterday, 12:18 AM   #5
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,784
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by Quoth View Post
Only starting a new file at a header works on everything.
Yes, of course. But there may be subheadings within a single chapter that, if they start on a new page, could disrupt the flow of the story. In these cases, it's helpful to have a way to avoid a page break immediately after those subheadings. ADE 2.x honors "page-break-after: avoid" since always and now ereaders based on webkit/readium finally gave support to "-webkit-column-break-after: avoid", so virtually any halfway decent e-reader can avoid a page break after a heading.

But there are still some "tricks" that allow you to avoid page breaks even without appealing to those properties, with simple CSS 2.0 declarations (that is 1998, the prehistory of CSS) that work on any e-reader that supports the margin and padding properties (and I find it hard to imagine that there is an e-reader that doesn't support them).
RbnJrg is offline   Reply With Quote
Old Yesterday, 06:12 AM   #6
Quoth
Still reading
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 14,106
Karma: 105211945
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
As ever ebook formats were initially only designed with novels in mind. Really most of the need for headings not starting on a new page is non-fiction, and even reflowable epub3 is still poor for scholarly works or textbooks, which is why those often use PDF.

I know about what you mention @RbnJrg, but fortunately it's only in notes / appendix of stuff I create that it would be needed and one option is to ignore it as long as the main content is OK
Quoth is offline   Reply With Quote
Old Yesterday, 06:22 AM   #7
rjwse@aol.com
Addict
rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.
 
rjwse@aol.com's Avatar
 
Posts: 324
Karma: 2228060
Join Date: Dec 2013
Location: LaVernia, Texas
Device: kindle epub readers on android
I use break-after:avoid and it has never failed me. It works well both in epub and after the epub has been converted via calibre to pdf for printing. I use it on centered, bold one-liners of <div style="break-after:avoid">…</div>. This also works well if you want to keep top-caption always together with image below it. (I must admit top-captioned images are less common than images followed by bottom captions.) For the most part I find it more useful to have an image with a bottom AND top caption. I use break-after:avoid as a class and pop it into place with a calibre snippet.
Attached Thumbnails
Click image for larger version

Name:	Screenshot from 2025-07-25 05-13-32.png
Views:	13
Size:	466.4 KB
ID:	217097   Click image for larger version

Name:	Screenshot from 2025-07-25 05-13-51.png
Views:	12
Size:	366.7 KB
ID:	217098   Click image for larger version

Name:	Screenshot from 2025-07-25 05-14-20.png
Views:	12
Size:	550.5 KB
ID:	217099   Click image for larger version

Name:	Screenshot from 2025-07-25 05-14-59.png
Views:	12
Size:	458.5 KB
ID:	217100  
rjwse@aol.com is offline   Reply With Quote
Old Yesterday, 11:03 AM   #8
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,784
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by Quoth View Post
As ever ebook formats were initially only designed with novels in mind.
That's right.

Quote:
Really most of the need for headings not starting on a new page is non-fiction, and even reflowable epub3 is still poor for scholarly works or textbooks, which is why those often use PDF.
The ePub format has improved significantly and now also allows for use in technical and non-fiction books. Consider the following images from Aristotle's Rhetoric:

Click image for larger version

Name:	One1.jpg
Views:	10
Size:	83.7 KB
ID:	217112 Click image for larger version

Name:	One2.jpg
Views:	10
Size:	104.1 KB
ID:	217113 Click image for larger version

Name:	One3.jpg
Views:	9
Size:	106.0 KB
ID:	217114

The interesting thing about this is that those screenshots are from an epub2 opened in KOReader! When the book doesn't have images and its design isn't too complicated (I mean, it doesn't have a dynamic layout that needs to change depending on the e-reader's screen size and the font size used by the user), the epub2 protocol can still compete with epub3, even for technical and non-fiction books.

Quote:
I know about what you mention @RbnJrg, but fortunately it's only in notes / appendix of stuff I create that it would be needed and one option is to ignore it as long as the main content is OK
Okay, it's your choice, and I respect that. But since it's cheap now and works well to avoid unwanted page breaks, it doesn't hurt to consider using it.
RbnJrg is offline   Reply With Quote
Old Yesterday, 12:43 PM   #9
Quoth
Still reading
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 14,106
Karma: 105211945
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
Or page breaks that are too annoying.

I think we are on the same page
Quoth is offline   Reply With Quote
Reply

Tags
header text keep together


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Change the header/footer text size. bmcs Calibre 2 03-09-2020 06:13 AM
Possible to remove header text? eTIPS Kindle Formats 2 08-19-2015 06:33 AM
Stripping a file from header text? norweger PDF 8 03-11-2015 03:49 PM
Getting text length from mobi header. mattst Kindle Formats 7 03-29-2012 06:31 AM
PDF Conversion - Removing Header / Footer Text heb Sony Reader 9 07-11-2010 11:02 PM


All times are GMT -4. The time now is 01:39 AM.


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