Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 03-09-2021, 02:11 AM   #1
what
Enthusiast
what began at the beginning.
 
Posts: 28
Karma: 10
Join Date: Mar 2021
Device: none
Advantage of a <div> wrapping the page content

In many ePubs that I own, the headers (<h1> etc.) and paragraphs (<p>) of the page content are wrapped in an division element (<div>), e.g.:

Code:
<html>
...
<body>
    <div>
        <h1>Chapter Heading</h1>
        <p>The text of the chapter.</p>
    </div>
</body>
</html>
Sometimes the <body> and <div> are styled, usually defining margins, sometimes they are both unstyled.

What are the advantages and disadvantages of wrapping my page content in a <div>, and (why) should I do it?
what is offline   Reply With Quote
Old 03-09-2021, 03:29 AM   #2
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,548
Karma: 19500001
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
The only advantage I can think of is that a <div> allows you to have inline elements at the same level as the main block elements. In principle things like <img> or <span> are by default inline elements (even if they are styled with display:block), and are not allowed (at least in XHTML 1.1) as direct children of <body>, they must be inside some block element, and the wrapping <div> does it.

I wouldn't use it unless I need that trick for some particular case.
Jellby is offline   Reply With Quote
Advert
Old 03-09-2021, 01:41 PM   #3
phillipgessert
Addict
phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.phillipgessert ought to be getting tired of karma fortunes by now.
 
phillipgessert's Avatar
 
Posts: 316
Karma: 3196766
Join Date: Oct 2015
Location: Madison, WI
Device: Kindle 5th Gen
Some tools add divs like that by default. I believe pandoc does, for example. So it's not always something done intentionally to achieve a result.
phillipgessert is online now   Reply With Quote
Old 03-11-2021, 11:23 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,743
Karma: 145864619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
I use Diaps Editing Toolbag plugin (for the Calibre editor) to remove such empty divs.They don't do a thing.
JSWolf is online now   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Content servers web page in Chrome RobertBB Server 2 10-27-2019 03:33 AM
Home page of the content server. Laval Related Tools 1 02-23-2018 10:29 PM
control div box, page breaks and margins? Lancelot ePub 4 09-21-2013 04:38 PM
element 'a' is not allowed for content model div JoanneM Workshop 6 11-22-2011 11:12 PM
iLiad Page Indicator for the Content Lister Michele L.M. iRex Developer's Corner 16 12-28-2008 08:43 AM


All times are GMT -4. The time now is 03:41 PM.


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