![]() |
#1 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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> |
![]() |
![]() |
![]() |
#2 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 769
Karma: 1537886
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; } ![]() Last edited by enuddleyarbl; 10-14-2022 at 08:57 PM. Reason: screenshot of poem |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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; } |
![]() |
![]() |
![]() |
#4 | |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 368
Karma: 1000000
Join Date: Mar 2016
Device: none
|
Quote:
|
|
![]() |
![]() |
![]() |
#5 | |
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 44,825
Karma: 168802811
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Quote:
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; } |
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 368
Karma: 1000000
Join Date: Mar 2016
Device: none
|
A fake list is an interesting idea. I like it.
|
![]() |
![]() |
![]() |
#7 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 769
Karma: 1537886
Join Date: Sep 2013
Device: Kobo Forma
|
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).
|
![]() |
![]() |
![]() |
#8 |
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,543
Karma: 19001583
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
|
![]() |
![]() |
![]() |
#9 | |
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,543
Karma: 19001583
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
Quote:
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> |
|
![]() |
![]() |
![]() |
#10 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,607
Karma: 9500498
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 |
![]() |
![]() |
![]() |
#11 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
Quote:
(It's towards the very end of that post in "Side Note #2".) I use 3 classes:
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. ![]() 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. |
|
![]() |
![]() |
![]() |
#12 | |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,312
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
|
Quote:
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> |
|
![]() |
![]() |
![]() |
#13 | |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 769
Karma: 1537886
Join Date: Sep 2013
Device: Kobo Forma
|
Quote:
![]() ![]() 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 { Code:
div.poetry p { 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. |
|
![]() |
![]() |
![]() |
#14 | |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 368
Karma: 1000000
Join Date: Mar 2016
Device: none
|
Quote:
Nonetheless, a lot of good stuff here to give some thought to. Cheers all. |
|
![]() |
![]() |
![]() |
#15 |
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,543
Karma: 19001583
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. |
![]() |
![]() |
![]() |
|
![]() |
||||
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 |