Theme

Pagination widows, or, Why I’m embarrassed about my ebook

The physical copies of my book on Web Typography sold out quickly. I self-published, and print runs are expensive when you’re funding them yourself, so numbers were limited. However it was always my plan to publish an ebook at the same time, and that has out-sold the hard copy by an order of magnitude.

I set myself some pretty stiff criteria for the ebook – it needed to replicate the design of print edition as far as possible, adapting to the medium when required. To this day I’m proud of the result. I completely hand-coded the ePub (meaning it’s mostly HTML and CSS under the hood), and I believe the effort paid off. If you’ll forgive the rather un-British boasting, I still think it’s one of the more advanced ebooks out there: with embedded fonts, SVG images, alt text, bold typographic heirarchy, Javascript-driven syntax highlighting and what I hope is a nuanced, highly readable overall design. Not bad for an ebook anyway, although I’ll grant you the bar is not set high (notable exceptions include A Book Apart publications).

All hubris aside, I am still frequently embarrassed by how the ebook renders, particularly in Apple Books. Like a well structured webpage, my book uses a lot of headings and subheadings – I wrote it to be referenced as much as to be read, so this helps the scanability of the text. However Apple Books, and other WebKit, Gecko, or old Blink-powered ebook readers will happily do this to headings:

Screen shot of Apple Books rendering an ePub

Notice the orphaned heading “Lean on six centuries of typesetting experience” with its following paragraph out of sight on the next page. This is a typographic no-no, and has been for – um – six centuries. Far better for the reader to have the heading attached to its paragraph on the next page, even if that means leaving some redundant whitespace in its place.

Since 1997(!) and the early drafts of CSS2, there has been an easy way to tell browsers not insert a page break directly after, or in the middle of, a heading:

h2 {
    page-break-after: avoid;
    page-break-inside: avoid;
}

Nowadays the modern way to do that is defined in the CSS Fragmentation Module Level 3 even more simply as:

h2 {
    break-after: avoid;
    break-inside: avoid;
}

However 26 years later, break-after:avoid is still not supported by either Safari or Firefox, and was only introduced to Chrome 108 in December 2022. I’ve put together a test for support of break-after and break-inside in multi-column layout. Have a play with it in Chrome – try removing break-inside:avoid and then break-after:avoid from the h2 rule in the CSS and you should see how the subheadings end up at the bottom of a column, or worse still, split over two columns.

Browser support for CSS properties tends to follow demand from web developers. Unlike in 1997 – or indeed 2017 – there is now an annual Interop arrangement between browser rendering engine makers in which they agree a common list of priorities for CSS and other web technologies. Interop 2024 has just closed for new proposals. Unfortunately I didn’t manage to submit a request in time for breaking controls to be universally implemented. Thankfully Scott Kellum of Typetura did put in a proposal for advanced multi-column layouts to be improved, and this included support for break- properties. Sadly there’s little to no clamour for it from other developers – the blog post you’re reading probably doubles the published demand, and that’s just for within columns.

Update: Annoyingly the proposal was not selected for Interop 2024 or Interop 2025. I'll just have to keep prodding the bug reports and keep my fingers crossed they are fixed soon – these bugs are older than some of my colleagues!

Paged media is very much a forgotten aspect, and it’s probably true that web pages are rarely printed in the grand scheme of things, however ebooks are definitely a popular form of paged media and deserve attention. I’d certainly like to read ebooks without failed typographic fundamentals.