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-04-2025, 01:28 PM   #1
Slevin#7
Connoisseur
Slevin#7 began at the beginning.
 
Posts: 61
Karma: 10
Join Date: May 2025
Device: iPad
How to margin p-Tag for PocketBook?

I wanna design for the PocketBook Reader app (iOS and Android) and keep struggling to set margins for paragraphs. Although PocketBook processes margins for div and some other tags properly, it refuses to apply my custom settings to p-tags. I've even raised precedence to almost maximum, but no satisfaction in sight...

HTML
Code:
<p>First Paragraph</p>
<p>Second Paragraph</p>
CSS
Code:
p {
  margin: 3em 0;
}
I have attached an EPUB2 with simple CSS styles, applying both shorthand and single set margins. Maybe someone would be so nice to take a quick look or at least can confirm that I'm not crazy

Many thanks for any help,
Slevin
Attached Thumbnails
Click image for larger version

Name:	pocketbook_screenshot.jpeg
Views:	38
Size:	1.02 MB
ID:	216689  
Attached Files
File Type: epub pocketbook_p_test.epub (2.6 KB, 19 views)
Slevin#7 is offline   Reply With Quote
Old 07-04-2025, 01:49 PM   #2
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,764
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by Slevin#7 View Post
I wanna design for the PocketBook Reader app (iOS and Android) and keep struggling to set margins for paragraphs. Although PocketBook processes margins for div and some other tags properly, it refuses to apply my custom settings to p-tags. I've even raised precedence to almost maximum, but no satisfaction in sight...

HTML
Code:
<p>First Paragraph</p>
<p>Second Paragraph</p>
CSS
Code:
p {
  margin: 3em 0;
}
I have attached an EPUB2 with simple CSS styles, applying both shorthand and single set margins. Maybe someone would be so nice to take a quick look or at least can confirm that I'm not crazy

Many thanks for any help,
Slevin
Yes, PocketBook has issues to set margins on p tags. If you need a special margin for a particular <p>, then employ <div> or <span> and this last one with the property "display: block". Or employ padding for those p tags who needs margins; it's not the same but, depending on the layout of your epub it could work. Also if you want to try, could use "-webkit-margin-before:3em;" and/or "-webkit-margin-after:3em".

Last edited by RbnJrg; 07-05-2025 at 11:21 AM.
RbnJrg is offline   Reply With Quote
Old 07-04-2025, 02:26 PM   #3
Moonbase59
Groupie
Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.
 
Moonbase59's Avatar
 
Posts: 165
Karma: 196896
Join Date: Oct 2021
Location: Germany
Device: Tolino Vision 5, Tolino Tab 8", Pocketbook Era (16GB)
In general, it’s never a good idea to target a specific reader. EPUB is supposed to be a reflowing format that should work on all readers equally good.

But you can, of course—freedom of choice. ;-)
Moonbase59 is online now   Reply With Quote
Old 07-05-2025, 10:47 AM   #4
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: 79,745
Karma: 145864619
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 RbnJrg View Post
Yes, PocketBook has issues to set margins on p tags. If you need a special margin for a particular <p>, then employ <div> or <span> and this last one with the property "display: block". Or employ padding for those p tags whor needs margins; it's not the same but, depending on the layout of your epub it could work. Also if you want to try, could use "-webkit-margin-before:3em;" and/or "-webkit-margin-after:3em".
Or just use RMSDK to view the ePub as that works for margin on a p tag.
JSWolf is offline   Reply With Quote
Old 07-05-2025, 06:39 PM   #5
Slevin#7
Connoisseur
Slevin#7 began at the beginning.
 
Posts: 61
Karma: 10
Join Date: May 2025
Device: iPad
Quote:
Originally Posted by RbnJrg View Post
If you need a special margin for a particular <p>, then employ <div> or <span> and this last one with the property "display: block". Or employ padding for those p tags who needs margins; it's not the same but, depending on the layout of your epub it could work.
This could be a workaround for some special cases, but since we wanna design the whole ebook with lots of paragraphs having margins, it just seems odd to replace tons of p-tags with semantically incorrect divs. Also, if a reader is that stubborn on one of the most basic CSS features, it might just not be the reader of our choice

Quote:
Originally Posted by RbnJrg View Post
Also if you want to try, could use "-webkit-margin-before:3em;" and/or "-webkit-margin-after:3em".
Thanks for the tip, I didn't know about that property - seems to be one of the more ebook targeting ones. However, I've tried "-webkit-margin-before: 3em !important;" and its modern variation "margin-block-start: 3em !important;" but unfortunately without any success.

I will try to contact PocketBook (again) and tell them friendly to fix their bug - although I think they would prefer to stay in the mindset that this is a feature.

Quote:
Originally Posted by Moonbase59 View Post
In general, it’s never a good idea to target a specific reader. EPUB is supposed to be a reflowing format that should work on all readers equally good.
You should be right, but unfortunately the creators of the reader software don't agree with you. So the only way to have an ebook which doesn't look like crap is to make a minimum working base version which at least shows all the text and images, no matter how ugly, and then pamper it bit by bit for the target readers you wanna support. It's just like it was years ago with all the many browsers, at least we don't need to take the IE with special targeting hacks any more into account.

Quote:
Originally Posted by JSWolf View Post
Or just use RMSDK to view the ePub as that works for margin on a p tag.
That is the framework to build your own ebook reader, right? Well, this would definitely be a solution for a big publishing company, but we are just a bunch of normal people who wanna provide ebooks for our community, so all the challenges and difficulties which come with that (ie. releasing apps on the Apple app store) are not worth the effort. But thanks for the tip anyways.
Slevin#7 is offline   Reply With Quote
Old 07-06-2025, 03:42 AM   #6
Moonbase59
Groupie
Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.
 
Moonbase59's Avatar
 
Posts: 165
Karma: 196896
Join Date: Oct 2021
Location: Germany
Device: Tolino Vision 5, Tolino Tab 8", Pocketbook Era (16GB)
Just had a quick look, and tried your file on a Pocketbook Era, the Calibre Viewer, Foliate and Thorium. All behave the same (and rightly so), because your CSS in styles.css is at fault, not any of the readers.

Code:
body {
  font-family: "Literata", serif;
}

body > p.p {
  margin: 1em 0 !important;
}

body > .p1.p1 {
  margin: 3em 0 !important;
}

body > .p2.p2 {
  margin-top: 3em !important;
  margin-right: 0 !important;
  margin-bottom: 3em !important;
  margin-left: 0 !important;
}
I have made a little change, removed the unneeded !important, added some text at the beginning of the paragraph CSS and made the background lightgray and the paragraph background white, so you can more easily spot what’s happening here.

Code:
body {
  font-family: "Literata", serif;
}

p {
  margin: 1em 0;
  background-color: white; /* remove when done */
}

p.p1 {
  margin: 3em 0;
  background-color: white; /* remove when done */
}

p.p2 {
  margin-top: 3em;
  margin-right: 0;
  margin-bottom: 3em;
  margin-left: 0;
  background-color: white; /* remove when done */
}

/* Show what's happening */
body {
  background-color: lightgray;
}

p::before {
  content: '(P) ';
}

p.p1::before {
  content: '(P1) ';
}

p.p2::before {
  content: '(P2) ';
}
The modified EPUB and CSS are in the attached ZIP for you to study. This version works nicely (and behaves the same) on all readers noted above. I also include actual screenshots from a Pocketbook Era, and from Foliate.

I don’t have any Pocketbook Apps here, but if they use the same (or at least a compliant) renderer in those apps, it should display the same. I’m not sure about iOS, Apple probably forces everyone to use their WebKit engine (from Safari), so for more special features you might have to use the -webkit-prefixes in addition there. Try to use as few as possible. Vendor-specific is evil. Like you say, we’ve had that with IE, back in the days.

Hint: Try to start out with easy CSS, don’t overcomplicate it.
Attached Thumbnails
Click image for larger version

Name:	scr0008.png
Views:	31
Size:	121.5 KB
ID:	216749   Click image for larger version

Name:	scr0009.png
Views:	29
Size:	93.2 KB
ID:	216750   Click image for larger version

Name:	P Margin Test_001.png
Views:	26
Size:	233.6 KB
ID:	216751  
Attached Files
File Type: zip Test Files.zip (3.1 KB, 21 views)

Last edited by Moonbase59; 07-06-2025 at 04:11 AM.
Moonbase59 is online now   Reply With Quote
Old 07-06-2025, 04:31 AM   #7
Slevin#7
Connoisseur
Slevin#7 began at the beginning.
 
Posts: 61
Karma: 10
Join Date: May 2025
Device: iPad
Quote:
Originally Posted by Moonbase59 View Post
The modified EPUB and CSS are in the attached ZIP for you to study. This version works nicely (and behaves the same) on all readers noted above. I also include actual screenshots from a Pocketbook Era, and from Foliate.

I don’t have any Pocketbook Apps here, but if they use the same (or at least a compliant) renderer in those apps, it should display the same. I’m not sure about iOS, Apple probably forces everyone to use their WebKit engine (from Safari), so for more special features you might have to use the -webkit-prefixes in addition there. Try to use as few as possible. Vendor-specific is evil. Like you say, we’ve had that with IE, back in the days.
Yeah, what I thought, unfortunately it seems to be a bug in the iOS app. All other reader work fine, and since you can confirm that your kind of PocketBook works as well, it is an application issue. Can't say whether Android is affected too, but I will find out the next days.

Quote:
Originally Posted by Moonbase59 View Post
All behave the same (and rightly so), because your CSS in styles.css is at fault, not any of the readers.

Hint: Try to start out with easy CSS, don’t overcomplicate it.
If you mean ".p1.p1" that's perfectly fine CSS, it's somewhat called raising precedence by connecting a class to itself and often used to avoid "!important". You could even do "p.p1.p1" and get a further level up. It's not a CSS functionality per definition, but also not faulty. I've never encountered a browser which didn't honor it, but maybe that is different with ebook readers. However, this was a last ressort after none of the previous attempts succeeded.

I've written CSS for over 20 years and am still willing to learn more, although there is a reason I mostly developed backend: predictability

Thank you and wish you a nice sunday

Last edited by Slevin#7; 07-06-2025 at 04:33 AM.
Slevin#7 is offline   Reply With Quote
Old 07-06-2025, 05:00 AM   #8
Moonbase59
Groupie
Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.
 
Moonbase59's Avatar
 
Posts: 165
Karma: 196896
Join Date: Oct 2021
Location: Germany
Device: Tolino Vision 5, Tolino Tab 8", Pocketbook Era (16GB)
Quote:
Originally Posted by Slevin#7 View Post
[…] it seems to be a bug in the iOS app. […]
Pity. Looks like Safari/WebKit are becoming the new IE… I know why I keep away from Apple’s golden-cage expensive lifestyle products with reduced functionality. Then again, you might have to cater for that audience, too…

Let us know about that, and Android, too.

Quote:
Originally Posted by Slevin#7 View Post
[…] wish you a nice sunday
Same to you!
Moonbase59 is online now   Reply With Quote
Old 07-06-2025, 05:16 AM   #9
Slevin#7
Connoisseur
Slevin#7 began at the beginning.
 
Posts: 61
Karma: 10
Join Date: May 2025
Device: iPad
Quote:
Originally Posted by Moonbase59 View Post
Pity. Looks like Safari/WebKit are becoming the new IE…
Can't say whether PocketBook uses the webkit engine or something else, but Apple Books (Apple's own reader) works as expected - and to be honest, it's one of the better ones.

What was I even thinking, that in 2025 all the silly differences would eventually converge and issues of this kind would only be known as anachronism...
Slevin#7 is offline   Reply With Quote
Old 07-06-2025, 11:48 AM   #10
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,764
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by Slevin#7 View Post
Can't say whether PocketBook uses the webkit engine or something else.
On Android, PocketBook employs an old version of webkit to rendering epub2/3 ebooks and also RMSDK to render epub2. Users can choose what engine is employed to read epubs.
RbnJrg is offline   Reply With Quote
Old 07-06-2025, 01:31 PM   #11
Slevin#7
Connoisseur
Slevin#7 began at the beginning.
 
Posts: 61
Karma: 10
Join Date: May 2025
Device: iPad
Quote:
Originally Posted by RbnJrg View Post
On Android, PocketBook employs an old version of webkit to rendering epub2/3 ebooks and also RMSDK to render epub2. Users can choose what engine is employed to read epubs.
Well, then that seems to be the case with iOS too, where you can go for an alternative renderer as well - which renders ebooks the same ugly way ADE does.
Slevin#7 is offline   Reply With Quote
Old 07-06-2025, 02:14 PM   #12
Moonbase59
Groupie
Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.Moonbase59 can program the VCR without an owner's manual.
 
Moonbase59's Avatar
 
Posts: 165
Karma: 196896
Join Date: Oct 2021
Location: Germany
Device: Tolino Vision 5, Tolino Tab 8", Pocketbook Era (16GB)
So it’s down to the least common denominator… Sometimes things just suck.
Moonbase59 is online now   Reply With Quote
Old 07-07-2025, 05:05 PM   #13
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: 79,745
Karma: 145864619
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 RbnJrg View Post
On Android, PocketBook employs an old version of webkit to rendering epub2/3 ebooks and also RMSDK to render epub2. Users can choose what engine is employed to read epubs.
Some Pocketbook Readers have the latest version of RMSDK as part of the firmware,
JSWolf is offline   Reply With Quote
Old 07-07-2025, 05:07 PM   #14
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: 79,745
Karma: 145864619
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 Slevin#7 View Post
Well, then that seems to be the case with iOS too, where you can go for an alternative renderer as well - which renders ebooks the same ugly way ADE does.
There is a version of ADE for iOS.
JSWolf is offline   Reply With Quote
Old 07-08-2025, 06:15 AM   #15
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,023
Karma: 105092227
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
Quote:
Originally Posted by JSWolf View Post
Some Pocketbook Readers have the latest version of RMSDK as part of the firmware,
Pocketbook app on Android probably isn't the same as a Pocketbook HW reader.
Quoth is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to tag PDFs with Calibre for PocketBook 740? eLDeus Library Management 7 07-01-2023 07:03 PM
Bottom margin ignored when tag is enclosed within a Div and paragraph spans two pages paperback Viewer 9 03-18-2023 02:02 PM
Tag Mapper: Remove tag if another specific tag exists? ownedbycats Library Management 2 07-23-2020 10:32 PM
calibre ignore margin-top and margin-bottom bender Calibre 2 12-11-2009 06:58 AM


All times are GMT -4. The time now is 12:51 PM.


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