![]() |
#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? |
![]() |
![]() |
![]() |
#2 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,023
Karma: 144284074
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 | |
|
![]() |
#3 |
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 443
Karma: 3367292
Join Date: May 2013
Location: Ontario, Canada
Device: Kindle KB, Oasis, Pop_Os!, 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. |
![]() |
![]() |
![]() |
#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
![]() |
![]() |
![]() |
![]() |
#5 | |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,023
Karma: 144284074
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
|
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 24,905
Karma: 47303824
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.
|
![]() |
![]() |
![]() |
#7 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,021
Karma: 90000009
Join Date: Nov 2011
Location: Charlottesville, VA
Device: Kindles
|
Is this something you are doing for yourself on a particular device or are you planning to publish?
|
![]() |
![]() |
![]() |
#8 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,602
Karma: 9500498
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:
|
|
![]() |
![]() |
![]() |
#9 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,023
Karma: 144284074
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. |
![]() |
![]() |
![]() |
#10 |
Member
![]() Posts: 11
Karma: 10
Join Date: Feb 2022
Device: Kindle
|
Sample
Here you go
![]() |
![]() |
![]() |
![]() |
#11 | |
Member
![]() Posts: 11
Karma: 10
Join Date: Feb 2022
Device: Kindle
|
Quote:
![]() |
|
![]() |
![]() |
![]() |
#12 |
Member
![]() Posts: 11
Karma: 10
Join Date: Feb 2022
Device: Kindle
|
|
![]() |
![]() |
![]() |
#13 | |
Member
![]() Posts: 11
Karma: 10
Join Date: Feb 2022
Device: Kindle
|
Quote:
![]() |
|
![]() |
![]() |
![]() |
#14 | |
Member
![]() Posts: 11
Karma: 10
Join Date: Feb 2022
Device: Kindle
|
Quote:
|
|
![]() |
![]() |
![]() |
#15 | |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,023
Karma: 144284074
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 | 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 |