Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 10-14-2022, 08:23 PM   #1
bookman156
Addict
bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.
 
Posts: 368
Karma: 1000000
Join Date: Mar 2016
Device: none
A bit of poetry CSS you may find useful

I was annoyed that long lines in poems, when they broke, would look like a new line, I was using br tags.

Then it dawned on me how to get the broken bit to indent. Just do this:

Code:
p.poem {
    text-indent: -1em;
    margin-left: 1em;
}
Code:
<p class="poem">This is a poetry line</p>
<p class="poem">This is a long long long poetry line</p>
<p class="poem">This is an long long even longer long poetry line</p>
bookman156 is offline   Reply With Quote
Old 10-14-2022, 08:46 PM   #2
enuddleyarbl
Guru
enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.
 
enuddleyarbl's Avatar
 
Posts: 734
Karma: 1077122
Join Date: Sep 2013
Device: Kobo Forma
I've gone a similar route, but with div classes:
Code:
div.poem {
/* Poem Styling */
	display: block;
	font-size:	.88em;
    font-style: italic;
	margin-left:	2em;
	margin-right:	2em;
	padding-left:	1.5em;
	text-align:	left;
}
div.poem p {
/* Poem Paragraph Styling */
	display:	block;
	margin-top:	0;
	margin-bottom:	0;
	text-indent:	-1.5em;
}
div.poem p.first {
/* Poem First Line */
	display:	block;
	padding-top:	1em;
}
div.poem p.indented {
/* Poem Entirely Indented Stanza */
	display:	block;
	margin-left:	2em;
}
div.poem p.last {
/* Poem Last Line */
	display:	block;
	padding-bottom:	1em;
}
The padding-left in the base poem class gives me more of a block-indent.

Last edited by enuddleyarbl; 10-14-2022 at 08:57 PM. Reason: screenshot of poem
enuddleyarbl is offline   Reply With Quote
Advert
Old 10-14-2022, 08:54 PM   #3
bookman156
Addict
bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.
 
Posts: 368
Karma: 1000000
Join Date: Mar 2016
Device: none
Interesting. I also use this:

Code:
p.poemspace, p.poem {
    text-indent: -1em;
    margin-left: 2.5em;
}

p.poemspace {
    padding-top: 1.2em;
}
Not sure why you need divs, is there any advantage in that approach do you think?
bookman156 is offline   Reply With Quote
Old 10-14-2022, 08:56 PM   #4
bookman156
Addict
bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.
 
Posts: 368
Karma: 1000000
Join Date: Mar 2016
Device: none
Quote:
The padding-left in the base poem class gives me more of a block-indent.
That's effectively a hanging indent, in typographical terms.
bookman156 is offline   Reply With Quote
Old 10-14-2022, 09:14 PM   #5
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: 36,169
Karma: 145735366
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by bookman156 View Post
I was annoyed that long lines in poems, when they broke, would look like a new line, I was using br tags.

Then it dawned on me how to get the broken bit to indent. Just do this:

Code:
p.poem {
    text-indent: -1em;
    margin-left: 1em;
}
Code:
<p class="poem">This is a poetry line</p>
<p class="poem">This is a long long long poetry line</p>
<p class="poem">This is an long long even longer long poetry line</p>
Reminds me of the CSS I've been using for quite a while to fake a list by using a hanging indent.

Code:
.fakelist {
  display: block;
  margin-bottom: 0.5em;
  margin-left: 2.5em;
  margin-right: 1.25em;
  margin-top: 0.5em;
  text-align: left;
  text-indent: -1.25em;
}
DNSB is offline   Reply With Quote
Advert
Old 10-14-2022, 09:27 PM   #6
bookman156
Addict
bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.
 
Posts: 368
Karma: 1000000
Join Date: Mar 2016
Device: none
A fake list is an interesting idea. I like it.
bookman156 is offline   Reply With Quote
Old 10-14-2022, 09:31 PM   #7
enuddleyarbl
Guru
enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.
 
enuddleyarbl's Avatar
 
Posts: 734
Karma: 1077122
Join Date: Sep 2013
Device: Kobo Forma
Quote:
Originally Posted by bookman156 View Post
...Not sure why you need divs, is there any advantage in that approach do you think?
I think it was Turtle91 (Dion?) who edged me into using the divs. They let me treat semantic objects as one unit (in this case, the div.poem) and then define structures that apply only within that object (the base paragraph and the first and last variations for top and bottom padding).
enuddleyarbl is offline   Reply With Quote
Old 10-15-2022, 02:53 AM   #8
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,516
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Ahem: https://www.mobileread.com/forums/sh...32&postcount=4
Jellby is offline   Reply With Quote
Old 10-15-2022, 02:57 AM   #9
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,516
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by Jellby View Post
Nowadays I use something like:

Code:
div.poetry {
  margin: 1em 0 1em 2em;
}
div.poetry div.stanza {
  margin: 0.5em 0 0.5em 0;
}
div.poetry div.line {
  margin: 0;
  padding-left: 3em;
  text-indent: -3em;
  text-align: left;
}
div.poetry div.line2 {
  margin: 0;
  padding-left: 5em;
  text-indent: -3em;
  text-align: left;
}
Code:
<div class="poetry">
<div class="stanza>
<div class="line">Verse line</div>
<div class="line">Verse line</div>
<div class="line2">Indented verse line</div>
</div>

<div class="stanza">
<div class="line">Verse line</div>
<div class="line">Verse line</div>
<div class="line2">Indented verse line</div>
</div>
</div>
Jellby is offline   Reply With Quote
Old 10-15-2022, 03:16 AM   #10
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,146
Karma: 4911876
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
The poetry code in Chapter 3 of Alice In Wonderland is quite intricate and well done...

Download epub here... https://www.mobileread.com/forums/sh...31#post3939531
Karellen is offline   Reply With Quote
Old 10-15-2022, 08:48 AM   #11
Tex2002ans
Wizard
Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.
 
Posts: 2,297
Karma: 12126329
Join Date: Jul 2012
Device: Kobo Forma, Nook
Quote:
Originally Posted by bookman156 View Post
Not sure why you need divs, is there any advantage in that approach do you think?
I explained my poetry code in:

(It's towards the very end of that post in "Side Note #2".)

I use 3 classes:
  • <div class="poem">
    • Gets its own top/bottom/left/right spacing.
  • <div class="stanza">
    • Gets its own top/bottom spacing.
    • Helps organize + keep each stanza together.
  • <p class="poem">
    • Each line + Negative indent.

All the details are described in that thread, especially the usage of page-break-inside: avoid.

Advantages are in code readability/maintainability + very easy to tweak.

Quote:
Originally Posted by Jellby View Post
Nowadays I use something like:

[...]
Yep. I second anything that Jellby says.

(He's the one who taught me about all that poetry stuff years and years ago.)

We agree on 99%, and only disagree on some minor differences (he says <div>, because "poetry isn't paragraphs"... and I still insist on <p>).

Last edited by Tex2002ans; 10-15-2022 at 09:02 AM.
Tex2002ans is offline   Reply With Quote
Old 10-15-2022, 09:53 AM   #12
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,117
Karma: 18727091
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
Quote:
Originally Posted by Tex2002ans View Post
We agree on 99%, and only disagree on some minor differences (he says <div>, because "poetry isn't paragraphs"... and I still insist on <p>).
Lolz. Yup, div is more semantically correct, but I use <p> as well… it saves a micro-bit or two on file size, and it’s a little cleaner IMO.

I also tend to define a default style rather than putting a class on every line:

Code:
div.poetry {
  margin: 1em 0 1em 2em;
}

div.poetry p {
  margin: 0;
  padding-left: 3em;
  text-indent: -3em;
  text-align: left;
}

div.poetry p.indent {
  margin: 0;
  padding-left: 5em;
  text-indent: -3em;
  text-align: left;
}

div.poetry p.space {
  margin-top: 1em;
}
Code:
<div class="poetry">
  <p>line of poetry</p>
  <p class="indent">indented line of poetry</p>
  <p>line of poetry</p>

  <p class="space">line of poetry in new stanza</p>
  <p>line of poetry</p>
  <p>line of poetry</p>

  <p class="space">line of poetry in new stanza</p>
  <p>line of poetry</p>
  <p>line of poetry</p>
</div>
Obviously there are many ways to skin that cat!
Turtle91 is offline   Reply With Quote
Old 10-15-2022, 10:00 AM   #13
enuddleyarbl
Guru
enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.
 
enuddleyarbl's Avatar
 
Posts: 734
Karma: 1077122
Join Date: Sep 2013
Device: Kobo Forma
Quote:
Originally Posted by Jellby View Post
Hey! Look! You use practically the same formatting as I do!

But, seriously, I should have remembered your post as being the origin of what I use. I even started a thread a few months back asking about it. Sorry.

Regarding your new poetry classes, I see that your div.stanza is handling the spacing of the stanzas that used to be handled by "first" and "last". But, if that's the case, I'd probably just override p instead of defining "line". IOW, instead of:
Code:
div.poetry div.line {
I'd have gone with:
Code:
div.poetry p {
That would keep the html a bit cleaner at the expense of some re-enforcement of the semantics that everything in the div is a poem.

The semantics of "line2" vs "indented" is a bit of a pickle, too. Is the fact that it's a line more or less important than that it's indented? Maybe "lineindent" or something might be more informative. But, that's too much typing.

EDIT: which is pretty much what Turtle91 posted just above me.

Last edited by enuddleyarbl; 10-15-2022 at 10:06 AM.
enuddleyarbl is offline   Reply With Quote
Old 10-15-2022, 10:43 AM   #14
bookman156
Addict
bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.bookman156 ought to be getting tired of karma fortunes by now.
 
Posts: 368
Karma: 1000000
Join Date: Mar 2016
Device: none
Quote:
he says <div>, because "poetry isn't paragraphs"... and I still insist on <p>
That's a good point, that poetry lines aren't paragraphs, that hadn't occurred to me. But then, they're not divs either are they?

Nonetheless, a lot of good stuff here to give some thought to. Cheers all.
bookman156 is offline   Reply With Quote
Old 10-15-2022, 01:20 PM   #15
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,516
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
I just use "line2" (in this particular example) because it was the second "kind" of line I encountered. Too often I encounter different pieces of poetry, in the same book, with varying indent amounts, I've become lazy now and called them simply "line2", "line3", etc.

<div> vs. <p>, I'm not going to fight about. Yes, I do think <div> is semantically more appropriate, and I could have used "div.stanza div" or similar, but I've also learnt that using classes instead of relying on a particular structure is more robust (I'm likely to find a case where I want to use a proper <p> inside a poem, or another <div> level...). As with class names, use whatever you like.

However, the margin/padding + negative indent trick is only a cludge. What we would need is:

1) Vertically centering the whole poetry block, without knowing it advance how wide it is.
2) Breaking lines by aligning the 2nd part to the right, as in the attachment. I'm not sure this is common in English, but it's certainly done in Spanish.[*]
[*] Fitting the broken part of the line in the next ("[spirital") or even previous ("[andar") line would be extra nice, but I'm not asking for that yet.
Attached Thumbnails
Click image for larger version

Name:	Screenshot_20221002_110110.png
Views:	83
Size:	121.8 KB
ID:	197183  
Jellby is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Anyone performance tested the calibre 32bit vs 64 bit on Windows 7 32 bit & 64 bit? millan Devices 6 11-07-2014 05:03 PM
A bit of css help for a Kindle Fixed template holdit Kindle Formats 2 03-01-2014 04:06 AM
Modern Poetry EBOOK Where to Find? pdubois Reading Recommendations 7 10-14-2011 10:22 PM
A bit of poetry Joebill Writers' Corner 4 01-08-2010 11:01 AM


All times are GMT -4. The time now is 10:40 AM.


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