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

Go Back   MobileRead Forums > E-Book Formats > Workshop

Notices

Reply
 
Thread Tools Search this Thread
Old 02-08-2022, 07:13 AM   #1
stellatus
Member
stellatus began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Feb 2022
Device: Kindle
headings, always stick to paragraphs

What to do to make headings always stick to paragraphs? Actually, the idea is that they should be sticked to the first two or three lines of a paragraph. In other words: I would like to prevent the header from breaking the page within a single HTML file. All indications are that CSS instructions are responsible for this:
1) page-break-after: avoid
2) page-break-inside: avoid.
However, they do not work. Why? How to solve this problem?
stellatus is offline   Reply With Quote
Old 02-08-2022, 09:10 AM   #2
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 73,887
Karma: 128597114
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
There's no need for page breaks of any kind. If the heading and these paragraphs do break it's because they are (as a whole) too large for the screen. Otherwise, they will be together on the same screen.
JSWolf is offline   Reply With Quote
Advert
Old 02-08-2022, 10:18 AM   #3
retiredbiker
Addict
retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.
 
retiredbiker's Avatar
 
Posts: 383
Karma: 1638210
Join Date: May 2013
Location: Ontario, Canada
Device: Kindle KB, Oasis, Ubuntu, Jutoh,Kobo Forma
Those page-break codes are very unreliable across various readers, I always remove them.

Separate your files so that each html file starts with your header. Then each header will start a new screen on just about any reader, and like JSWolf said, only a huge header, bigger than the screen or with too much spacing, will separate itself from the text.
retiredbiker is offline   Reply With Quote
Old 02-08-2022, 11:07 AM   #4
stellatus
Member
stellatus began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Feb 2022
Device: Kindle
@JSWolf, @retiredbiker Thanks for your answers. "Separate your files so that each html file starts with your header. Then each header will start a new screen on just about any reader" That's what I did before I wrote the post. My book has 3 levels of headings: h1, h2 and h3, that is parts -> chapters -> "subchapters". As for h1 and h2, of course this solution is perfect. However, there are a lot of "subchapters" and they are often short. As a result, there are a lot of blank spaces in this book, and it looks very strange
stellatus is offline   Reply With Quote
Old 02-08-2022, 11:29 AM   #5
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 73,887
Karma: 128597114
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by stellatus View Post
@JSWolf, @retiredbiker Thanks for your answers. "Separate your files so that each html file starts with your header. Then each header will start a new screen on just about any reader" That's what I did before I wrote the post. My book has 3 levels of headings: h1, h2 and h3, that is parts -> chapters -> "subchapters". As for h1 and h2, of course this solution is perfect. However, there are a lot of "subchapters" and they are often short. As a result, there are a lot of blank spaces in this book, and it looks very strange
Can you make up a sample ePub that we can have a look at?
JSWolf is offline   Reply With Quote
Advert
Old 02-08-2022, 09:39 PM   #6
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
@stellatus: Wrapping a div around the parts you want to keep together with a style that includes "page-break-inside: avoid" should work. That worked on my Kobo with an epub. As the others have said, it isn't supported in all ereaders or apps.
davidfor is offline   Reply With Quote
Old 02-08-2022, 09:55 PM   #7
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: 6,496
Karma: 84420419
Join Date: Nov 2011
Location: Tampa Bay, Florida
Device: Kindles
Is this something you are doing for yourself on a particular device or are you planning to publish?
jhowell is online now   Reply With Quote
Old 02-08-2022, 10:25 PM   #8
Karellen
Wizard
Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.
 
Karellen's Avatar
 
Posts: 1,089
Karma: 4911876
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
Confirming what @davidfor has stated, I have used the following code in two novels which works well reading on my Libra2...

Code:
.nopagebreak {
  page-break-inside: avoid;
  margin-left: inherit;
  margin-right: inherit;
}
Then in the body of the text I use...

Quote:
<div class="nopagebreak">
<h3 id="toc_1">1b</h3>

<p>This is the first paragraph of the sub-chapter. This paragraph should stick to the sub-heading</p>
</div>
Karellen is online now   Reply With Quote
Old 02-09-2022, 04:18 AM   #9
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 73,887
Karma: 128597114
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
But you don't need a div with a pagebreak. It's irrelevant because it's at the top of the screen. It's either going to fit together on the screen or it isn't. That depends on the size of the text and the size of the screen. These are variables you cannot control if you are not the one reading the book. And if you are worried about it fitting, don't use a large amount of excess space around the header like most publishers do.

Last edited by JSWolf; 02-09-2022 at 04:22 AM.
JSWolf is offline   Reply With Quote
Old 02-09-2022, 06:05 AM   #10
stellatus
Member
stellatus began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Feb 2022
Device: Kindle
Sample

Quote:
Originally Posted by JSWolf View Post
Can you make up a sample ePub that we can have a look at?
Here you go sample.epub
stellatus is offline   Reply With Quote
Old 02-09-2022, 06:21 AM   #11
stellatus
Member
stellatus began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Feb 2022
Device: Kindle
Quote:
Originally Posted by davidfor View Post
@stellatus: Wrapping a div around the parts you want to keep together with a style that includes "page-break-inside: avoid" should work. That worked on my Kobo with an epub. As the others have said, it isn't supported in all ereaders or apps.
On my Kindle 4.1.3, it doesn't work for sure
stellatus is offline   Reply With Quote
Old 02-09-2022, 06:23 AM   #12
stellatus
Member
stellatus began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Feb 2022
Device: Kindle
Quote:
Originally Posted by jhowell View Post
Is this something you are doing for yourself on a particular device or are you planning to publish?
I'm planning to publish it.
stellatus is offline   Reply With Quote
Old 02-09-2022, 06:24 AM   #13
stellatus
Member
stellatus began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Feb 2022
Device: Kindle
Quote:
Originally Posted by Karellen View Post
Confirming what @davidfor has stated, I have used the following code in two novels which works well reading on my Libra2...

Code:
.nopagebreak {
  page-break-inside: avoid;
  margin-left: inherit;
  margin-right: inherit;
}
Then in the body of the text I use...
Awesome! Good to know
stellatus is offline   Reply With Quote
Old 02-09-2022, 06:28 AM   #14
stellatus
Member
stellatus began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Feb 2022
Device: Kindle
Quote:
Originally Posted by JSWolf View Post
But you don't need a div with a pagebreak. It's irrelevant because it's at the top of the screen. It's either going to fit together on the screen or it isn't. That depends on the size of the text and the size of the screen. These are variables you cannot control if you are not the one reading the book. And if you are worried about it fitting, don't use a large amount of excess space around the header like most publishers do.
It looks like that's what I will have to do. But I'm going to leave those page-brake-after instructions, etc. in the CSS because it works on some readers.
stellatus is offline   Reply With Quote
Old 02-09-2022, 09:13 AM   #15
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 73,887
Karma: 128597114
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by stellatus View Post
It looks like that's what I will have to do. But I'm going to leave those page-brake-after instructions, etc. in the CSS because it works on some readers.
But these page breaks are 100% useless. The header and paragraph will fit or they won't fit. A page break avoid will not make something fit that doesn't fit. Because this is at the top of the page, it will split if it has to. If it doesn't fit on the first page of the chapter, it won't fit on any page. So just let it be split if it needs to be instead of something going wrong when a program tries to keep everything together but cannot do so.

It would be like a <pre> when the text is too wide and you cannot see some of it.
JSWolf is offline   Reply With Quote
Reply

Tags
css, headings, page-break

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
DOCX paragraphs listed as headings in navigation window tage fredheim Conversion 2 07-26-2019 07:11 AM
How to convert ''Headings'' to ''HEADINGS''? chaot Workshop 13 03-16-2017 03:32 PM
How to separate paragraphs and headings in Book View amoroso Sigil 2 07-12-2010 08:27 AM
Collections saved to Memory Stick without a memory stick jabberwock_11 Sony Reader 11 01-09-2009 09:48 PM
SD card vs. memory stick vs. high speed memory stick wadood Sony Reader 20 05-10-2007 03:58 PM


All times are GMT -4. The time now is 09:49 PM.


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