Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 07-28-2022, 06:17 PM   #1
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: 744
Karma: 1077122
Join Date: Sep 2013
Device: Kobo Forma
Poetry Classes: Blockquote vs Div?

I found Jellby's snippet of CSS for poetry:

https://www.mobileread.com/forums/sh...32&postcount=4

But, since it's 13 years old, I felt pretty silly trying to ask about it there. So...

Quote:
Originally Posted by Jellby View Post
...
css:
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.indented {
  margin-left: 2em;
}
div.poetry p.first {
  margin-top: 1em;
}
So, use class="first" when a new stanza begins and class="indented" for indented lines.

For pieces with more complex indent pattern or for mainly poetry works I'd probably do something different, like a <div></div> for each stanza (which could include "page-break-inside: avoid" in the css).
Is it possible to put classes like this on blockquote instead of div? Is it even desirable? I'm to the point where I've played around with enough books' CSS that using blockquotes as a single solution for walls-o'-text, poetry and letters (i.e., Dear Sir...) is starting to grate. I'm considering classes for poetry and letters and leaving wall-o'-text at just plain blockquote. But, I wonder what's the least complex/most understandable way to do it.
enuddleyarbl is offline   Reply With Quote
Old 07-28-2022, 06:24 PM   #2
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: 311
Karma: 3196258
Join Date: Oct 2015
Location: Madison, WI
Device: Kindle 5th Gen
Quote:
Originally Posted by DaveLessnau View Post
I found Jellby's snippet of CSS for poetry:

https://www.mobileread.com/forums/sh...32&postcount=4

But, since it's 13 years old, I felt pretty silly trying to ask about it there. So...



Is it possible to put classes like this on blockquote instead of div? Is it even desirable? I'm to the point where I've played around with enough books' CSS that using blockquotes as a single solution for walls-o'-text, poetry and letters (i.e., Dear Sir...) is starting to grate. I'm considering classes for poetry and letters and leaving wall-o'-text at just plain blockquote. But, I wonder what's the least complex/most understandable way to do it.
Are you asking whether you can set poetry using <blockquote>? That's how I do it if it's within another work, like a poem someone's reciting in a novel. If it's for a book of straight poetry, I don't think that would be quite correct semantically and probably not much benefit. I'd wrap each stanza in a <div> for that (Jelly's second method in that quoted post).
phillipgessert is offline   Reply With Quote
Advert
Old 07-28-2022, 07:24 PM   #3
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: 744
Karma: 1077122
Join Date: Sep 2013
Device: Kobo Forma
Yes. Almost invariably in what I do, this would be for snippets of poetry quoted as supporting flavors in a book. Things like an epigraph or the starts of chapters.
enuddleyarbl is offline   Reply With Quote
Old 07-28-2022, 07:35 PM   #4
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: 311
Karma: 3196258
Join Date: Oct 2015
Location: Madison, WI
Device: Kindle 5th Gen
Yeah, I always do those as blockquotes. Like you it starts to feel like a lot of blockquoting after a while but I personally wouldn’t switch to divs or anything for that. Seems like a downgrade.
phillipgessert is offline   Reply With Quote
Old 07-28-2022, 10:04 PM   #5
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,182
Karma: 18843349
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
blockquotes and divs can be styled to look identical - the difference is almost pure semantics. The only big difference is that you can set the "cite" attribute within the blockquote tag, divs you don't.

If you change the css from Jelby's example above to this it will look identical.

Code:
blockquote.poetry {
  margin: 1em 0 1em 2em;
}
blockquote.poetry p {
  margin: 0;
  padding-left: 3em;
  text-indent: -3em;
  text-align: left;
}
blockquote.poetry p.indented {
  margin-left: 2em;
}
blockquote.poetry p.first {
  margin-top: 1em;
}
Like phillipgessert, I would use a div for poetry unless it was part of a longer quote - then semantically blockquote would be more correct.
Turtle91 is offline   Reply With Quote
Advert
Old 07-29-2022, 12:38 AM   #6
Sarmat89
Evangelist
Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.
 
Posts: 495
Karma: 2267928
Join Date: Nov 2015
Device: none
blockquotes are indented by default, divs are not, so blockquote is the reasonable choice.
Sarmat89 is offline   Reply With Quote
Old 07-29-2022, 04:32 AM   #7
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: 75,860
Karma: 134368292
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
One thing, don't use the margin shorthand. Use the separate margin lines such as margin-top: margin-right:. It's a lot easier to read the CSS that way.

As for div.poetry p, 3em is too large. Think of reading this on a small cell phone screen. You already have a 2em margin. 1em is better. Also, you don't need padding and you don't need left align.

Code:
blockquote.poetry {
  margin-top: 1em;
  margin-right: 0;
  margin-bottom: 1em;
  margin-left: 2em;
}
blockquote.poetry p {
  margin-top: 0;
  margin-right: 0;
  margin-bottom: 0;
  margin-left: 1.5em;
  text-indent: -1.5em;
}
blockquote.poetry p.indented {
  margin-left: 2em;
}
blockquote.poetry p.first {
  margin-top: 1em;
}

Last edited by JSWolf; 07-29-2022 at 04:40 AM.
JSWolf is offline   Reply With Quote
Old 07-29-2022, 06:53 AM   #8
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,182
Karma: 18843349
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:
Originally Posted by Sarmat89 View Post
blockquotes are indented by default, divs are not, so blockquote is the reasonable choice.
Definitely a “no” on that reasoning.

1. You should not make choices of html tags based on the way it looks, but by what the tag is meant to define:
Use a <p> to define a paragraph
Use a <table> to define a table
Use a <blockquote> to define a long quote
Use a <div> to define a section of html that should be treated separately from surrounding html.
Etc.
Technically you could use a <div> to define EVERYTHING in your html but it would not be semantically correct. Devices/apps may not function correctly if they can’t distinguish the <tags> properly.

2. Never rely on some “default” behavior - always explicitly define the presentation you want to see in your attached css stylesheet. It’s difficult to find devices/apps that consistently follow the published standards let alone some nebulous, undefined, “default”.
You need to define how much of an indent you want, does that indent apply to just the first line or the whole section, does the indent vary when the user changes the font size or is it a fixed distance, is the indent measured from the parent container’s border or is it from the edge of the screen.

Last edited by Turtle91; 07-29-2022 at 06:59 AM.
Turtle91 is offline   Reply With Quote
Old 07-29-2022, 07:55 AM   #9
Quoth
the rook, bossing Never.
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 12,249
Karma: 89531599
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
Also if you only want to edit in MS Word or LO Writer you might have less divs and certainly with LO Writer and perfectly formatted poetry and lyrics I never ever see blockquote generated. Just <p class="somestyle"

Also if you use ePub to proof read in the edit cycle you absolutely don't want to ever edit the HTML and CSS, except maybe for the "publish version" and I can't remember ever having to edit more than some CSS for the styles of images in maybe the last 6 years.

Good advice on "Never rely on some 'default' behaviour". So when I use a list format/style in LO Writer the bullets or auto increment (letters, numbers or Roman) are explicitly typed in. No doubt the "auto" feature saves time renumbering items when you go back and insert and extra, but it creates compatibility issues and isn't worth it. Similarly we don't auto number chapter headings.

Of course tables are tricky on ereaders on smaller screens or user selecting a large font. Can be tricky on Web on Mobile even with a "responsive" theme, which no doubt is why historically WordPress had no tables, you added a plug-in.
Quoth is offline   Reply With Quote
Old 07-29-2022, 11:15 AM   #10
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: 744
Karma: 1077122
Join Date: Sep 2013
Device: Kobo Forma
Quote:
Originally Posted by JSWolf View Post
One thing, don't use the margin shorthand. Use the separate margin lines such as margin-top: margin-right:. It's a lot easier to read the CSS that way.

As for div.poetry p, 3em is too large. Think of reading this on a small cell phone screen. You already have a 2em margin. 1em is better. Also, you don't need padding and you don't need left align.

Code:
blockquote.poetry {
  margin-top: 1em;
  margin-right: 0;
  margin-bottom: 1em;
  margin-left: 2em;
}
blockquote.poetry p {
  margin-top: 0;
  margin-right: 0;
  margin-bottom: 0;
  margin-left: 1.5em;
  text-indent: -1.5em;
}
blockquote.poetry p.indented {
  margin-left: 2em;
}
blockquote.poetry p.first {
  margin-top: 1em;
}
I was playing with this stuff last night and found the same issues you mentioned. I went through and specified margin types and reduced the padding/indent to something more reasonable.

I also decided to set up div classes for poems, songs and letters. I'll use blockquotes for more generic blocks of quotes (<- )
enuddleyarbl is offline   Reply With Quote
Old 07-29-2022, 11:18 AM   #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: 75,860
Karma: 134368292
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Speaking of padding, padding is best used in a section break if you plan on using blank space.

[code].sectionbreak {
padding-top: 2em;
text-indent: 0;
}[/quote]

The reason for this is the margin gets lost when it's at the bottom/top of the screen. The padding does not get lost.
JSWolf is offline   Reply With Quote
Old 07-29-2022, 02:02 PM   #12
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,533
Karma: 19000001
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
One difference between blockquote and div is that a blockquote cannot (if you want to comply with the standard[*], anyway) contain inline elements as direct children, it can only contain block-level elements.

So this is wrong:
Code:
<blockquote>Foo</blockquote>
but this is fine:
Code:
<div>Foo</div>
[*] I don't remember which standard, it might have changed in newer ones, but epub 2 still uses HTML 4 something.
Jellby is offline   Reply With Quote
Old 07-29-2022, 02:07 PM   #13
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,533
Karma: 19000001
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by JSWolf View Post
As for div.poetry p, 3em is too large. Think of reading this on a small cell phone screen.
The 3em is for indenting wrapped lines, it's cancelled by the negative text-indent. As long as you can distinguish wrapped lines from double-indented lines, it should be fine.

Quote:
Also, you don't need padding and you don't need left align.
The padding is to prevent it being overridden by other margin specifications. You need left align if you don't want your poetry lines (the wrapped lines, at least) to be justified when the user selects justification for the main text.
Jellby is offline   Reply With Quote
Old 07-29-2022, 02:10 PM   #14
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,533
Karma: 19000001
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
By the way, I no longer use <p> for each line, I use just another <div> or <div class="line">, verse lines are not paragraphs.
Jellby is offline   Reply With Quote
Old 07-29-2022, 02:24 PM   #15
hobnail
Running with scissors
hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.
 
Posts: 1,555
Karma: 14325282
Join Date: Nov 2019
Device: none
If you're like me the word block in the blockquote's name may make you feel like it's the correct thing to use for things like poetry, letters, etc. But as Turtle91 points out, the blockquote has a cite attribute, so a blockquote is meant for quoting something from a larger work. If you read the w3c's definition for blockquote they're quite firm about it being only for quoting something, not just a general purpose block of text that's visually set off from the surrounding text. If it wouldn't make sense to use the cite attribute when you use a blockquote then you're likely semantically correct to instead use a div.

I made the switch to div when Jellby or TeX pointed out that using blockquote for general blocks of text is incorrect. This is when I came up with the idea of using two classes; e.g., <div class="block poem">.

Anyhow, I bring this up in case you'd prefer to be semantically correct with your html.
hobnail is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pseudo classes to be deleted as unused classes Leonatus Sigil 2 09-23-2018 09:12 AM
Setting first line of a blockquote or div AlexBell ePub 2 06-19-2016 08:21 AM
Pseudo classes with classes Macsurfcat ePub 4 01-07-2016 04:00 AM
Div Selectors vs Paragraph Classes -- Robustness? GrannyGrump ePub 14 10-08-2013 08:49 AM
keeping or removing a div with multiple classes JohnsonZA Recipes 1 09-25-2010 10:33 AM


All times are GMT -4. The time now is 11:42 AM.


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