![]() |
#1 |
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 449
Karma: 65460
Join Date: Jun 2011
Device: Kindle
|
<div> instead of <p>?
This may be recency bias, but i feel like I've been seeing more and more epubs that use <div> to enclose basic text instead of <p>. That is, narry a <p> to be found throughout the whole book.
To my untrained eye this seems... kinda puzzling. Is there a good reason for this kind of substitution? Does <p> have outlier cases where it fails and <div> doesn't? |
![]() |
![]() |
![]() |
#2 |
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,549
Karma: 19500001
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
Probably generated with some software that creates only <div>s and <span>s?
|
![]() |
![]() |
![]() |
#3 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,764
Karma: 6000000
Join Date: Nov 2009
Device: many
|
Replacing p with div is just horrible from a semantic meaning basis. Code like that is broken imho, and as Jellby stated ... probably machine generated.
|
![]() |
![]() |
![]() |
#4 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,758
Karma: 145864619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
When I find those awful (IMHO) ePub with <div> instead of <p>, I replace the <div> with <p> where it should be <p>. And because the <div> and </div> are on separate lines, I search/replace all the lines so they run on. Then I use Modify ePub to split the lines properly. I will go through the code to see if I missed any <div> that should be <p>.
Does anyone know what software is being used to screw with <p>? |
![]() |
![]() |
![]() |
#5 |
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 46,220
Karma: 168983734
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
I do much the same but since the divs have classes, I replace only those <div class="whatever">...</div> blocks that are where a paragraph or header tag should be.
The only pain is where there are nested divs ( <div class="flush_para"><div class="italic_text"> for example ) which do take a bit of manual cleanup. |
![]() |
![]() |
![]() |
#6 |
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 518
Karma: 2268308
Join Date: Nov 2015
Device: none
|
People are using div's because it prevents empty lines between paragraphs.
|
![]() |
![]() |
![]() |
#7 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,353
Karma: 20171571
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
Why not just style the paragraph css appropriately?? Or if it’s the device inserting extra space when it shouldn’t, get a new device…. Or complain to the manufacturer!!
|
![]() |
![]() |
![]() |
#8 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,062
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
But WHY not set a margin: 0 if that is what is wanted? To me, <div> is a container to keep a grouping together. (pagebreak-inside-avoid) |
|
![]() |
![]() |
![]() |
#9 |
Running with scissors
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,587
Karma: 14328510
Join Date: Nov 2019
Device: none
|
I get those occasionally. I have an involved song and dance for how I convert a Kindle book to epub. Part of the work is done when Calibre converts it. The final/second step is opening it in Sigil and taking a big sledgehammer to its CSS with the following regexp which replaces these with nothing:
Code:
( display: block; | font-size: .* | letter-spacing:.* | line-break: strict; | line-height: .* | page-break-after:.* | page-break-before:.* | page-break-inside:.* | vertical-align: .* | white-space: pre-wrap; ) This often messes up the chapter titles making them the same size as the paragraph text because many if not most ebooks use the p tag instead of the h tags for chapter titles (another unforgivable sin). Edit: I should fix the above regexp and instead of having a space after the colon use a regexp for 0 or more spaces. I'm guessing that calibre's conversion is always putting a space after the colon. Last edited by hobnail; Yesterday at 12:00 AM. |
![]() |
![]() |
![]() |
#10 |
Groupie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 172
Karma: 1000000
Join Date: Oct 2021
Location: Germany
Device: Tolino Vision 5, Tolino Tab 8", Pocketbook Era (16GB)
|
What really annoys me is that you see more and more of this crap in expensive e-books from large publishers. The code often looks like machine-generated, or at least done by complete idiots. Also, there’s often stuff in it to fight deficiencies of single readers.
I mean, hey, in what market are we? Pay $10–30 for a book and then have to invest hours to repair it?! It really, really sucks. Besides, not everybody has the tools or the knowledge. |
![]() |
![]() |
![]() |
#11 |
Still reading
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 14,045
Karma: 105092227
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
|
I had one ebook from a large publisher all <div> instead of <p>
From every point of view that's stupidity. If <div> is used at all, it's an extra level of structure, not a tag for body paragraphs. Clue even in the name. How do they even manage such stupidity? I've only spent hours "repairing" an ebook if it's badly proofed OCR to be almost unreadable and it's part of a series and otherwise unobtainable. All of those from Amazon. I learnt years ago to only download PDFs from archive dot org, because their auto generated ebook formats are an insult and mostly unusable. Last edited by Quoth; Yesterday at 06:30 AM. |
![]() |
![]() |
![]() |
#12 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,758
Karma: 145864619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
|
![]() |
![]() |
![]() |
#13 |
Still reading
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 14,045
Karma: 105092227
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
|
|
![]() |
![]() |
![]() |
#14 | |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,758
Karma: 145864619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
So yes, there can be <div> even if the only images are the cover and the title page. |
|
![]() |
![]() |
![]() |
#15 |
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 518
Karma: 2268308
Join Date: Nov 2015
Device: none
|
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Using <p> instead of <div> | goderic | Sigil | 4 | 09-25-2024 11:12 AM |
A tag that's new to me <div/> | DyckBook | Editor | 7 | 11-13-2021 02:30 AM |
<div> problem | alheva | Marvin | 30 | 08-23-2016 09:13 PM |
duplicate div id's | thiefwriter | ePub | 6 | 09-17-2011 11:00 AM |
Center a div | marcelo2605 | ePub | 4 | 05-13-2011 07:39 AM |