![]() |
#1 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 141
Karma: 2784614
Join Date: Nov 2012
Device: none
|
How simple should I make the CSS?
It is my experience that whatever .epub I design will breaks a lot - images aren't displayed, fonts don't work, even a simple thing as italic text tends to break. And that is just on my own Kobo.
One thing I consider is to keep everything so simple that it cannot break - like typing in actual uppercase instead of using text-transform: uppercase;. Or use manual indenting instead of h2 + p { text-indent:0; } But how far should I go? Is there any way of telling what CSS I can expect to be implemented on most readers? |
![]() |
![]() |
![]() |
#2 |
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
|
Many things work fine in CSS. There are bunches of CSS examples in the wiki specific for ePub. italic text should work everywhere but text-transform is not to be trusted. text-indent is the preferred way to indent, ePub does not support all CSS so you need to be sure what you want is supported and not all readers follow CSS instructions. If you avoid depending on cascade you will be better off. Do a check of your CSS file for errors. An error in the file will cause the entire file to be ignored on Adobe based readers.
Dale |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,543
Karma: 19001583
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
text-transform, as DaleDe points out, is not included in the ePub spec, so you should not expect it to work, and in particular you should not depend on it.
visibility is another such property that would be useful in some cases. font-variant:smallcaps, however should be supported, but it mostly isn't, so you should not rely on it either (but you can blame the readers, and Adobe in particular, for that). Same with pseudo-elements (:first-letter, :first-line). auto margins will often not work as expected, because the spec allows them to be ignored, and they often are. Complex selectors (h2 + p, div.poetry div.stanza p, etc) in my experience work fine, but they may fail in some reader. Just don't try to be too smart. |
![]() |
![]() |
![]() |
#4 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 141
Karma: 2784614
Join Date: Nov 2012
Device: none
|
Both of you, thanks! :-)
So it's like this: USE: font-style: italic; text-indent: 1.3em; complex selectors (h2 + p, div.poetry, div.stanza p) mostly works, but don't get too smart. AVOID: text-transform: uppercase; visibility: hidden; font-variant:smallcaps; (but it *should* be supported) margin: auto; pseudo-elements (:first-letter, :first-line, :before ...). Also avoid cascade How about fonts? I guess that font-family: sans-serif; font-family: serif; will be safe, but can I trust that any of the 'web-safe-fonts' are on the system? And how about line-height and letter-spacing? Last edited by Kasper Hviid; 06-05-2013 at 07:13 AM. |
![]() |
![]() |
![]() |
#5 |
Color me gone
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,089
Karma: 1445295
Join Date: Apr 2008
Location: Central Oregon Coast
Device: PRS-300
|
Whatever fonts are on a reader is all there is unless you embed them into an epub. This increases the size, generally to not so much benefit. Many fonts, including some of those that come with a Windows system, are proprietary and can not be legally embedded without permission which is likely to cost more than you would make on a book. There are good non-proprietary fonts, and on Adobe's website is a list of their fonts that are embeddable.
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 141
Karma: 2784614
Join Date: Nov 2012
Device: none
|
thanks mrmikel! By the way, my reader has:
- Amasis - Avenir Next - Caecilia - Georgia - Gill Sans - Kobo Nickel - Malabar So basic "web safe fonts" like Arial and Times New Roman isn't supported. My guess is that one should just use either 'serif' or 'sans-serif' for .epub files that should be compatible on most devices ... for anything more precise, the fonts will need to be embedded. |
![]() |
![]() |
![]() |
#7 | |||
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,543
Karma: 19001583
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
Quote:
That is, I install "Droid Serif" and use it happily... but then some book sets "font-family: serif", and I see the default Adobe font, instead of "Droid Serif". So, I'd say avoid them. Use only fonts if you are embedding them, and don't use embedded fonts for the main text. Quote:
Quote:
line-height is, but that's something a bit like font-size: you better let the user choose the right one and don't mess with it, unless for some special effect in some particular section (I use "line-height:0" for superscripts, to avoid uneven line spacing, for instance). |
|||
![]() |
![]() |
![]() |
#8 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,022
Karma: 144284074
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
One thing you cannot do on a Kobo is use font-family in the body style. It doesn't work. Kobo ignores it. You have to use font-family in other CSS styles such as p.
Code:
p { font-family: Charis margin-top: 0; margin-bottom: 0; text-indent: 1.2em } |
![]() |
![]() |
![]() |
#9 |
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 580
Karma: 810184
Join Date: Sep 2010
Location: Norway
Device: prs-t1, tablet, Nook Simple, assorted kindles, iPad
|
I suppose the watch-words are “graceful decay”: the text should remain readable even if some, or even all, of the stylesheet is ignored.
Ignored CSS is simple enough to handle. The real bugbear is when CSS is interpreted differently in separate readers (line-height seems to be particularly awkward) I hasten to add that I myself spend very little effort attempting to live up to such a maxim. I make my epub books for the fun of it, and one of the really fun bits is messing around with the style sheet. Though maybe thus limiting “my” readership, I console myself with the thought that my uncompromising attitude may spur suppliers of epub readers to greater conformance (Yeah, right...) |
![]() |
![]() |
![]() |
#10 | |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,022
Karma: 144284074
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
|
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
css to make all images larger? | 1611mac | ePub | 5 | 03-31-2012 02:18 AM |
How do you hide/make not-visible sections in CSS/epub? | FatDog | ePub | 2 | 02-23-2012 05:54 PM |
Simple Question for the CSS experts out there... | Japes | Calibre | 2 | 06-23-2011 11:12 PM |
Tweak epub and Simple CSS Editor | Shadowman123 | Calibre | 11 | 09-30-2010 10:07 AM |
How can I make a left-justify CSS for CoolReader? | Sunspark | Astak EZReader | 1 | 06-07-2010 11:00 AM |