Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 01-19-2025, 11:17 AM   #1
ryder
Member
ryder began at the beginning.
 
Posts: 23
Karma: 10
Join Date: May 2024
Device: Clara 2E
CSS command instead of remove spacing between paragraphs

Hi everybody, is this code correct to use instead of the "remove spacing between paragraphs" in calibre or would there be some other problems created with it:

p {
margin: 0 !important;
padding: 0;
}

It looks great so far and there are no bugs found by calibre after converting.
Thanks a lot for the help.
ryder is offline   Reply With Quote
Old 01-19-2025, 01:38 PM   #2
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,592
Karma: 9499994
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
https://www2.mobileread.com/i/mr/editor/menupop.gif

I don't think you need the !important.

For the standard paragraph, I use...
p {
display: block;
margin-top: 0;
margin-bottom: 0;
text-indent: 1em;
}


Then, for those paragraphs that don't use an indent I use...
.noindent {
text-indent: 0;
}


Also, you need to check the css for the <body> tag in case it needs tweaking.

Great that it is slowly coming together for you. What ereader are you using?

And if it helps, here is my css in full which I adjust as needed on a per-book basis. Might give you some pointers...
https://paste.kodi.tv/rovohaxatu
Karellen is offline   Reply With Quote
Old 01-19-2025, 02:10 PM   #3
ryder
Member
ryder began at the beginning.
 
Posts: 23
Karma: 10
Join Date: May 2024
Device: Clara 2E
Quote:
Originally Posted by Karellen View Post
I don't think you need the !important.

For the standard paragraph, I use...
p {
display: block;
margin-top: 0;
margin-bottom: 0;
text-indent: 1em;
}


Then, for those paragraphs that don't use an indent I use...
.noindent {
text-indent: 0;
}


Also, you need to check the css for the <body> tag in case it needs tweaking.

Great that it is slowly coming together for you. What ereader are you using?

And if it helps, here is my css in full which I adjust as needed on a per-book basis. Might give you some pointers...
https://paste.kodi.tv/rovohaxatu

Thank you. I will try that. I am using a clara 2e. The last reader was a sony prs-t3. It handled my ebooks much better. Don't know why Kobo is so lazy with formatting and such. Are you editing from paragraph to paragraph or just via the conversion tool?
ryder is offline   Reply With Quote
Old 01-19-2025, 02:12 PM   #4
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,592
Karma: 9499994
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
I never use the conversion tool, nor any plugins. I just recode/reformat the entire epub. Main method I use is regex to make bulk fixes
Karellen is offline   Reply With Quote
Old 01-19-2025, 02:25 PM   #5
ryder
Member
ryder began at the beginning.
 
Posts: 23
Karma: 10
Join Date: May 2024
Device: Clara 2E
Quote:
Originally Posted by Karellen View Post
I never use the conversion tool, nor any plugins. I just recode/reformat the entire epub. Main method I use is regex to make bulk fixes
This sounds like a lot of work if you have many ebooks. Unfortunately I don't have the time for that. So the conversion tool is my goal.

I have noticed some ebooks had a black font color after the conversion. On the reader they look normal, but not when viewed in calibre (black letters on grey background). Is this a bug, because I use the dark mode on windows or is the css somehow broken? Who noticed this before?
ryder is offline   Reply With Quote
Old 01-19-2025, 02:43 PM   #6
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,592
Karma: 9499994
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
Quote:
Originally Posted by ryder View Post
This sounds like a lot of work if you have many ebooks. Unfortunately I don't have the time for that. So the conversion tool is my goal.

I have noticed some ebooks had a black font color after the conversion. On the reader they look normal, but not when viewed in calibre (black letters on grey background). Is this a bug, because I use the dark mode on windows or is the css somehow broken? Who noticed this before?
Sorry, I don't know about the issue of font colours. All I can say is that blindly pressing buttons hoping for a perfect outcome is misguided at best. You really need to understand what you are trying to accomplish, and by that you need to understand the basics of epub structure, css, html, xml and regex.

I started this about 4 years ago, and I had no clue on any of that. NO CLUE. You should have seen the mess I made of the first book. But quite a bit of reading, experimenting and it started to sink in. Then came across this forum, and picked up even more pointers from the very helpful members here.

Now about 500+ books later, I can do it in my sleep... almost. A somewhat clean book can be fixed within half an hour, but some books are a total mess and can take a few hours.

As for having time... what is the rush? Do you have a deadline that requires you to rush these books into distribution? Slow down, understand what it is you are doing, and you will save yourself quite a bit of stress and frustration when things aren't working out.
Karellen is offline   Reply With Quote
Old 01-19-2025, 03:19 PM   #7
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 44,451
Karma: 167726581
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
For what little it may be worth, I use the following for my base body and p CSS:

Code:
body {
  display: block;
  font-size: 1em;
  margin: 0 0 0 0;
  padding: 0 0 0 0;
  text-indent: 0;
  line-height: 1.05;
  widows: 1;
  orphans: 1;
}

p {
  display: block;
  text-indent: 0;
  line-height: 1.05;
  margin: 0 0 0 0;
  padding: 0.1em 0 0 0;
  margin-block-end: 0em;
}
The "padding: 0.1em 0 0 0;" is to add a minimal spacing between paragraphs which I personally happen to prefer.
DNSB is offline   Reply With Quote
Old 01-19-2025, 07:08 PM   #8
ryder
Member
ryder began at the beginning.
 
Posts: 23
Karma: 10
Join Date: May 2024
Device: Clara 2E
Quote:
Originally Posted by Karellen View Post
Sorry, I don't know about the issue of font colours. All I can say is that blindly pressing buttons hoping for a perfect outcome is misguided at best. You really need to understand what you are trying to accomplish, and by that you need to understand the basics of epub structure, css, html, xml and regex.

I started this about 4 years ago, and I had no clue on any of that. NO CLUE. You should have seen the mess I made of the first book. But quite a bit of reading, experimenting and it started to sink in. Then came across this forum, and picked up even more pointers from the very helpful members here.

Now about 500+ books later, I can do it in my sleep... almost. A somewhat clean book can be fixed within half an hour, but some books are a total mess and can take a few hours.

As for having time... what is the rush? Do you have a deadline that requires you to rush these books into distribution? Slow down, understand what it is you are doing, and you will save yourself quite a bit of stress and frustration when things aren't working out.
There is no rush actually, but family, job and sports are taken a big chunk of my precious free time. So the desire for a magic bullet fix is there. But I guess some ebooks need more work than others. Fortunately the ebooks from the stores are pretty decent formatted nowadays. I still remember the time when ebooks looked really horrible on ereaders back in 2010. Let's hope that one day the ereader will do this task all by themselves, no matter what ebook format style you throw at them.
ryder is offline   Reply With Quote
Old 01-19-2025, 07:12 PM   #9
ryder
Member
ryder began at the beginning.
 
Posts: 23
Karma: 10
Join Date: May 2024
Device: Clara 2E
Quote:
Originally Posted by DNSB View Post
For what little it may be worth, I use the following for my base body and p CSS:

Code:
body {
  display: block;
  font-size: 1em;
  margin: 0 0 0 0;
  padding: 0 0 0 0;
  text-indent: 0;
  line-height: 1.05;
  widows: 1;
  orphans: 1;
}

p {
  display: block;
  text-indent: 0;
  line-height: 1.05;
  margin: 0 0 0 0;
  padding: 0.1em 0 0 0;
  margin-block-end: 0em;
}
The "padding: 0.1em 0 0 0;" is to add a minimal spacing between paragraphs which I personally happen to prefer.
Thanks for your code. I will try that as well. What is the meaning of widows: 1; orphans: 1; Just one word at the beginning and end of a paragraph is allowed?
ryder is offline   Reply With Quote
Old 01-19-2025, 07:37 PM   #10
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: 78,918
Karma: 143098300
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 ryder View Post
Thank you. I will try that. I am using a clara 2e. The last reader was a sony prs-t3. It handled my ebooks much better. Don't know why Kobo is so lazy with formatting and such. Are you editing from paragraph to paragraph or just via the conversion tool?
This CSS for p is what I use. I edit the eBooks. I do not convert ePub to ePub. I also remove all of the <p class="indent"> (or whatever class they use for the main paragraph style and replace it with <p>. It's much neater code.

Code:
p {
  margin-top: 0;
  margin-bottom: 0;
  widows: 1;
  orphans: 1;
  text-indent: 1.2em;
}
JSWolf is offline   Reply With Quote
Old 01-19-2025, 07:39 PM   #11
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: 78,918
Karma: 143098300
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 ryder View Post
This sounds like a lot of work if you have many ebooks. Unfortunately I don't have the time for that. So the conversion tool is my goal.

I have noticed some ebooks had a black font color after the conversion. On the reader they look normal, but not when viewed in calibre (black letters on grey background). Is this a bug, because I use the dark mode on windows or is the css somehow broken? Who noticed this before?
That's why you have to hand edit the eBooks because you cannot automate everything as you don't know what the code looks like. So while the conversion may work in most cases, there are those where it will fail. By hand editing, you can fix other issues besides a color code for the text.
JSWolf is offline   Reply With Quote
Old 01-19-2025, 07:41 PM   #12
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: 78,918
Karma: 143098300
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 ryder View Post
Thanks for your code. I will try that as well. What is the meaning of widows: 1; orphans: 1; Just one word at the beginning and end of a paragraph is allowed?
I use the following body code because I cannot stand paragraph spaces no matter how small they are.

Code:
body {
  widows: 1;
  orphans: 1;
  margin-top: 0;
  margin-right: 0;
  margin-bottom: 0;
  margin-left: 0;
  text-align: justify;
}
Widows and orphans have a default value of 2. If at the end of the page, 1 line of the last paragraph is left, it will drop to the next page. You would need at least two lines of the last paragraph on the page. Windows deals with the end of the paragraph. So if one line drops to the next page, the window will make it so another line joins it and there are two lines. Basically, windows and orphans set to 1 turns them off.

Last edited by JSWolf; 01-19-2025 at 07:49 PM.
JSWolf is offline   Reply With Quote
Old 01-19-2025, 08:07 PM   #13
slm
Fool
slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.
 
Posts: 454
Karma: 4103210
Join Date: Feb 2003
Device: Kindle: Voyage,PW1,KOA, Kobo: Clara Colour, Nook GLP, Pocketbook verse
Quote:
Originally Posted by ryder View Post
Hi everybody, is this code correct to use instead of the "remove spacing between paragraphs" in calibre or would there be some other problems created with it:

p {
margin: 0 !important;
padding: 0;
}

It looks great so far and there are no bugs found by calibre after converting.
Thanks a lot for the help.
I think when you are just adding CSS via the conversion tool, the !important is important.

The reason I think this, although I haven't tried your code, is that many years ago (before Kindles and Kobos had much ability to darken fonts or select really dark fonts) I set my conversions to to the equivalent with font-weight and it worked very well. I originally did

*{font-weight:bold}

but the results were inconsistent.

Kovid suggested that I add !important, and it worked consistently.

Of course, I'm a lot less picky than some of the folk on this thread.

Good luck.
slm is offline   Reply With Quote
Old 01-19-2025, 09:00 PM   #14
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 44,451
Karma: 167726581
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by ryder View Post
Thanks for your code. I will try that as well. What is the meaning of widows: 1; orphans: 1; Just one word at the beginning and end of a paragraph is allowed?
Basically, you can have a line/word by itself at the top or bottom of a page. 1 is the lowest setting. If you set them to 2, you would have a minimum of two lines from a paragraph at the top or bottom of a page. To see the difference, widows would be alone at the top of a page while orphans would be alone at the bottom of the page. Of course, some people define it the other way around with widows at the bottom of the page and orphans alone at the top of a page.

Basically, since ereaders do not modify the line spacing the way that physical books can, you end up with varying gaps at the bottom of a page which the widows/orphans setting helps to reduce. In theory, an ereader could use microjustication (small changes to spacing between words and letters and lines) to make text more even on page but that takes quite a bit of CPU power and memory which most ereaders do not have.

Last edited by DNSB; 01-28-2025 at 04:42 PM. Reason: fixed typo that annoyed me everytime I saw it
DNSB is offline   Reply With Quote
Old 01-24-2025, 03:32 PM   #15
nabsltd
Fanatic
nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.
 
Posts: 517
Karma: 8500000
Join Date: Aug 2013
Location: Hamden, CT
Device: Kindle Paperwhite (11th gen), Scribe, Kindle 4 Touch
Quote:
Originally Posted by DNSB View Post
The "padding: 0.1em 0 0 0;" is to add a minimal spacing between paragraphs which I personally happen to prefer.
Do you use padding so it doesn't collapse? I use margin-bottom: 0.1em; specifically because I want it to collapse if the next paragraph happens to have a larger top margin (like after a section break).
nabsltd is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
There's no spacing between paragraphs Tior500 Conversion 1 12-02-2019 10:18 AM
CSS to indent paragraphs and remove spaces Alda Sigil 7 06-20-2014 05:36 AM
expression to remove double spacing between paragraphs ktj Calibre 4 07-26-2011 02:38 PM
Remove spacing between paragraphs - what about div tags ? NASCARaddicted Calibre 5 11-07-2009 05:47 AM
Remove spacing between paragraphs doesn't. Djehuty Calibre 6 04-28-2009 04:53 AM


All times are GMT -4. The time now is 08:06 AM.


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