Tag Archives: Glitches

Kindle CSS Weirdness

Here are some Kindle CSS gotchas I’ve come across recently. I’ll update this post with more such oddities as (or if) I come across them.

  • text-align:center; fails if designated as !important, even if the left and right margins are set to zero.
  • text-indent:0; fails (ignored). It works if you specify the measurement: text-indent:0em;

These quirks are present in each of the reader programs I tried: Kindle Previewer, Kindle for PC, and Mobipocket Reader. This leads me to suspect that they are bugs in Kindlegen rather than in the Kindle reading software; I don’t know how Kindlegen works but my guess is that it contains a CSS translator that generates inline formatting, leading to possibilities of flawed HTML being generated if the translation code isn’t spot-on. If so, we can hope that these quirks will be fixed in a future Kindlegen release. In the meantime, the potential work-arounds/trade-offs are obvious — but note that Stanza on iPad requires !important in order to center body text; you might want to force body text centering on Kindle by using <div style="text-align:center;"><p class="MyCenteredClass">...</p></div> instead, in order to maximise the portability of your ePub.

iBooks v1.2 File Update Failures and Glitches

When you transfer a new version of an ePub file into iBooks, it can fail to recognise the new information. Generally I find this to be a problem when fine-tuning CSS in order to improve a layout, because iBooks refuses to show my changes, making the edit-debug cycle incredibly frustrating; the last thing you want to see is the previous version of the book you’re developing. In Handcrafted Ebooks I mentioned that exiting iBooks and running different software would fix this. Unfortunately, this no longer works reliably with iBooks v1.2 and IOS 4.2, both of which were recently rolled out by Apple. Maybe it’s something to do with IOS 4.2’s multi-tasking abilities, allowing iBooks to cling more tenaciously than ever to phantom data; for whatever reason this problem now seems harder to clear by loading other applications.

Happily, the IOS 4.2 Task Manager (aka the Multitasking App Tray) lets you work around this as follows: exit iBooks, double-tap the Home button, and you will see a list of recent applications that includes iBooks. In this list, press and hold the iBooks icon until the red-circled ‘-’ sign appears, then tap that sign. The iBooks application should close, and vanish from the list. Double-tap Home to exit the App Tray, then re-start iBooks and re-open the book you’re working on. So far, this has worked reliably for me — and saved a lot of hair-pulling when incrementally testing new ePub versions.

Update, February 2011: iBooks version 1.2.1 seems to have improved the above issue. I now find that the following sequence is usually sufficient: 1. close the book in iBooks, returning to the app’s Library view. 2. Delete the old version of the book from within iTunes. 3. Drag the new version of the book into iTunes and wait for it to sync. 4. Open the book in iBooks. However, the occasional glitch can still occur, so you might still need to resort to the old method.

iBooks v1.2 for iPad Supports Auto-Hyphenation

This is a welcome update, and makes justified text more readable on iPad/iBooks. It also illustrates a benefit, discussed in Handcrafted Ebooks, that comes from leaving control in the hands of the user where possible. An ePub that doesn’t enforce justification choices, will “just work” with the new hyphenation feature.

On the downside: this new version seems to glitch sometimes when switching between chapters, re-displaying the same page repeatedly instead of moving to the desired new one. I never noticed this in the previous version, though that’s not conclusive proof that the issue didn’t exist there. In the limited v1.2 testing I’ve done so far, I’ve only seen this problem when viewing double-page spreads; switching iBooks to its single page view proved to be a work-around, as did selecting a different font or font size. Enabling or disabling auto-hyphenation made no difference. Time will tell if it’s going to be a problem that crops up a lot, and what if anything ePub creators can do to avoid it.

Update:I came across this again in the latest book I’m formatting, when I changed a line of CSS from this: h4.title {font-size:120%; margin-bottom:0.3em !important;} to this: h4.title {font-size:120%; margin: 0 0 0.3em 0 !important;}. I tried several alternative ways to force the top margin to be zero, both in my CSS file and inline with “style=…”, but all had the same effect of triggering the iBooks chapter-change bug with one particular text-size selection.