02-08-2022, 07:13 AM | #1 |
Member
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? |
02-08-2022, 09:10 AM | #2 |
Resident Curmudgeon
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.
|
Advert | |
|
02-08-2022, 10:18 AM | #3 |
Addict
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. |
02-08-2022, 11:07 AM | #4 |
Member
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
|
02-08-2022, 11:29 AM | #5 | |
Resident Curmudgeon
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:
|
|
Advert | |
|
02-08-2022, 09:39 PM | #6 |
Grand Sorcerer
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.
|
02-08-2022, 09:55 PM | #7 |
Grand Sorcerer
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?
|
02-08-2022, 10:25 PM | #8 | |
Wizard
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; } Quote:
|
|
02-09-2022, 04:18 AM | #9 |
Resident Curmudgeon
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. |
02-09-2022, 06:05 AM | #10 |
Member
Posts: 11
Karma: 10
Join Date: Feb 2022
Device: Kindle
|
Sample
Here you go sample.epub
|
02-09-2022, 06:21 AM | #11 |
Member
Posts: 11
Karma: 10
Join Date: Feb 2022
Device: Kindle
|
On my Kindle 4.1.3, it doesn't work for sure
|
02-09-2022, 06:23 AM | #12 |
Member
Posts: 11
Karma: 10
Join Date: Feb 2022
Device: Kindle
|
|
02-09-2022, 06:24 AM | #13 |
Member
Posts: 11
Karma: 10
Join Date: Feb 2022
Device: Kindle
|
Awesome! Good to know
|
02-09-2022, 06:28 AM | #14 | |
Member
Posts: 11
Karma: 10
Join Date: Feb 2022
Device: Kindle
|
Quote:
|
|
02-09-2022, 09:13 AM | #15 | |
Resident Curmudgeon
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:
It would be like a <pre> when the text is too wide and you cannot see some of it. |
|
Tags |
css, headings, page-break |
Thread Tools | Search this Thread |
|
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 |