05-24-2013, 09:51 PM | #1 |
Junior Member
Posts: 9
Karma: 10
Join Date: May 2013
Device: PocketBook Basic (613)
|
Making some % of first line different in new chapters?
Hi all,
In some books, the first line in every chapter is formatted differently. Is this possible in epub? I know there is some (at least semi) standard CSS element for this, :first-line, but I was unable to find any references to it being used in epub. Some books have the first three words different (and I suppose that's easy enough to format) while others have roughly half the line in italics. Is that possible at all automatically? If you want to look at a real book with this kind of formatting, you can look at The Ruby Knight by David Eddings. There each chapter starts with a drop cap and the first three (four if short) words in small caps. There's also ornamentation. |
05-24-2013, 10:54 PM | #2 |
A Hairy Wizard
Posts: 3,093
Karma: 18727053
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
Since the number of words per line changes based on screen size, font size, margin size etc. the best way I have found is to just use the pseudo-element :first-line. That works really well on devices that support it... . The ePub spec says: first-line and :first-letter are required to be supported but that doesn't mean they all do...
If you are making the book for public consumption you should stick with wrapping a span around the first few words for an italic or small caps effect...or easier still just highlight the first few words and click the all caps button to manually change them to caps. Last edited by Turtle91; 05-24-2013 at 10:58 PM. |
05-25-2013, 05:01 AM | #3 |
frumious Bandersnatch
Posts: 7,515
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
I would either use :first-line and not care about readers that don't support it (it's not a big deal, anyway), or apply the styling to some meaningful set of words, like just the first word (or two if the first is one letter), or the first "unit", such as "Mr. Smith", "The next day" or "Unfortunately".
|
05-25-2013, 07:04 AM | #4 |
Junior Member
Posts: 9
Karma: 10
Join Date: May 2013
Device: PocketBook Basic (613)
|
Thank you.
At the moment I'm just curious about these things. One other point for consideration for CSS magicians: In Assassin's Apprentice by Robin Hobb the first four words are small caps and in one place there's only one other word on the line; where the first four are long. I suppose there's no CSS magic to say "if this word is on the first line, make it different?" So that when someone zooms in and there less than four words on the line, only the ones on the first are different? I suppose that magic would somehow rely on :first-line being supported. |
05-25-2013, 08:17 AM | #5 |
A Hairy Wizard
Posts: 3,093
Karma: 18727053
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
Yes, that is exactly what first-line does. As Jellby mentioned, it is perfectly OK to use :first-line and :first-letter in your coding. If the device/app doesn't support it they should degrade gracefully - they should display just like a normal line/letter - the user won't even know they are supposed to be there.
|
05-25-2013, 08:24 AM | #6 |
Wizard
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
To my knowledge all ADE based readers will ignore it. I haven't heard if the kobo supports it, but I doubt it.
|
05-25-2013, 11:22 AM | #7 |
Grand Sorcerer
Posts: 11,470
Karma: 13095790
Join Date: Aug 2007
Location: Grass Valley, CA
Device: EB 1150, EZ Reader, Literati, iPad 2 & Air 2, iPhone 7
|
Another choice is to reference the first paragraph after a chapter header which is also a supported feature and likely to work on more readers.
Dale |
05-25-2013, 01:07 PM | #8 |
Wizard
Posts: 1,539
Karma: 6613969
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Please, read this thread:
https://www.mobileread.com/forums/sho...d.php?t=212300 https://www.mobileread.com/forums/sho...71&postcount=7 It's about mobi files but also is valid for epub files (in fact, you'll find there several epubs converted into mobis). |
05-25-2013, 04:14 PM | #9 |
Junior Member
Posts: 9
Karma: 10
Join Date: May 2013
Device: PocketBook Basic (613)
|
Thanks. Indeed, :first-line works in the firefox app, but not on my PocketBook. Does that mean it's an ADE?
I tried to use it for the first four words with a <span> but that failed. The paragraph: Code:
<p><span class="first">Ðe night after her</span> ninþ birþday, wearing a white nightgown, she tiptoed into her parents' bedroom. Her bare feet moved noiselessly over ðe floor. In her right hand she clutched a plush cþulhu doll.</p> Code:
span.first:first-line { font-style: italic; } |
05-25-2013, 05:25 PM | #10 |
Grand Sorcerer
Posts: 11,470
Karma: 13095790
Join Date: Aug 2007
Location: Grass Valley, CA
Device: EB 1150, EZ Reader, Literati, iPad 2 & Air 2, iPhone 7
|
I do not think you need the first-line in this case. The span is enough. You could just say .first or p.first and then set the content.
.first {font-style: italic} or p.first {font-style: italic; } Let's suppose you want the first line after a header to not indent you would set the standard p as: p {text-indent: 2em} but if you have: h1 + p {text-indent: 0} Then the first line after an h1 would not indent. This is equivalent to a first-line choice. Dale Last edited by DaleDe; 05-25-2013 at 05:27 PM. |
05-25-2013, 06:53 PM | #11 |
Junior Member
Posts: 9
Karma: 10
Join Date: May 2013
Device: PocketBook Basic (613)
|
Thank you.
No, I don't need the :first-line, the exercise was to determine if I could prevent words from being typeset differently in the case they ended up on the second line. To be specific: the aim was to typeset the first four words or the first line in italics. That is, in the case where there are only three words on the first line, I'd want the fourth normal. Seems I can't do that easily. |
05-25-2013, 09:00 PM | #12 | |
Grand Sorcerer
Posts: 11,470
Karma: 13095790
Join Date: Aug 2007
Location: Grass Valley, CA
Device: EB 1150, EZ Reader, Literati, iPad 2 & Air 2, iPhone 7
|
Quote:
Dale |
|
05-25-2013, 10:15 PM | #13 |
A Hairy Wizard
Posts: 3,093
Karma: 18727053
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
I agree you can't quite do what you want. The only thing you could do is set your :first-line attribute and then have a minimum number of words (in this example 4) that would be emphasized regardless of the reader's support of the pseudo selector. If the font was so large - or the screen so small - that only 3 words fit on the first line, the 4th word would still be emphasized on the second line. But that would be a pretty extreme situation to only fit 3 words on a line.
eg. CSS h1 + p {text-indent:0} h1 + p:firstline {font-style:italic} em {font-style:italic} HTML <h1>Heading Line</h1> <p><em>The first four words</em> are italic on non-supportive devices. The entire first line is italic on supportive devices.</p> -OR- h1 + p {text-indent:0} h1 + p:firstline {font-variant:small-caps} .smcap {font-variant:small-caps} <h1>Heading Line</h1> <p><span class="smcap">The first four words</span> are smallcaps on non-supportive devices. The entire first line is smallcaps on supportive devices.</p> |
05-27-2013, 03:06 AM | #14 |
frumious Bandersnatch
Posts: 7,515
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
|
05-27-2013, 08:38 AM | #15 |
A Hairy Wizard
Posts: 3,093
Karma: 18727053
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
|
Tags |
drop cap, epub, first line, small caps |
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Book chapters/story line | sunny1z | Sigil | 3 | 01-21-2013 11:06 PM |
epub to epub converting: making chapters? | Joy736 | Conversion | 8 | 10-30-2011 04:47 PM |
azw to mobi: Not detecting chapters/page break at chapters and no TOC | RachDvn | Calibre | 3 | 01-16-2011 09:53 AM |
HTML2EPUB Command Line for splitting chapters | stratman | Calibre | 6 | 01-22-2010 09:26 AM |