CSS Page Templates in ePUB 3.0
While the ePUB 3.0 specification was finalized in IDPF on October 11, 2011, the working group continues to work on various modules that may eventually be added to the ePUB 3.0 spec. One of these is CSS Page Templates, with the current module documentation released on January 19, 2012 (you might want to view the in Chrome to see the proper markup in the document).
What Is CSS Page Templates?
According to the Abstract at the beginning of the document,
This module defines a model for template-based paginated layouts as an extension to CSS, the style sheet language for the web. Using functionality described in the specification, content can be formatted into a sequence of richly designed interactive pages, rather than being presented as a single scrolled container (as per the standard CSS formatting process for on-screen display) or as a scrolled container which has been simply split up into a sequence of pages (as per the standard CSS formatting process for printing).
While this might appear at first blush to be something similar to Fixed-Layout ePUB, it really is not as the IDPF has a separate module for EPUB 3 Fixed-Layout Documents that was just released on February 22, 2012. To further understand CSS Page Templates, it is defined in the document as:
This module describes functionality to dynamically layout a document into a sequence of pages (or “screens”). Its primary focus is interactive display environments in which the page size and user preferred font metrics are unknown at the time of document authoring and layout has to be done on the fly. This module builds on CSS 2.1 and several CSS3 modules.
Basic Processing Model
The processing model defined by this specification enables a User Agent (UA) to flow content (such as HTML) into a series of linked containers separately described by CSS page templates . The separation of content and template is prevalent in document-oriented formatting systems, and enhances content reusability, accessibility, and expressivity. This specification also defines an associated means for style property selection to be parameterized based on dynamic conditions, such as the width of the display region.
The specification consists of two parts: adaptive styling and page layout. The adaptive styling consists of
- Calculated Values: ‘-epubx-expr()’
- Defining named values: the ‘@-epubx-define’ rule
- Conditional styling: ‘@-epubx-when’ rule
The page layout is quite extensive, and includes:
- Flows, partition and page masters
- Compatibility At-Rule: ‘@-epubx-page-template’
- Assigning CSS classes to Page Template at-rules
- Flow overview
- Definition/processing model for content eligibility rules
- Types of content in the flow: the ‘-epubx-flow-options’ property
- Flow content lifetime: the ‘-epubx-flow-linger’ property
- Flow content selection: the ‘-epubx-flow-priority’ property
- Controlling column/region/page breaking points
- Defining page layout: ‘@-epubx-page-master’ rule
- Allocating the page area: the ‘@-epubx-partition’ rule
- Grouping the partitions: the ‘@-epubx-partition-group’ rule
- Conditional page master and partition usage: the ‘-epubx-enabled’ property
- Using page layout for a particular page: the ‘-epubx-page’ property
- Selecting a page master based on device dimensions: the ‘-epubx-min-page-width’ and ‘-epubx-min-page-height’ properties
- Selecting a page master based on content: the ‘-epubx-required’ property
- Using only one in a set of partitions: the ‘-epubx-conflicting-partitions’ property
- Using multiple partitions together: the ‘-epubx-required-partitions’ property
- Snapping to the line grid : the ‘-epubx-snap-height’ property
- Lookup range: the ‘-epubx-utilization’ property
- Page Layout Processing Model
- Expressions inside the ‘@-epubx-page-master’ rule
- Styling content in a partition: the ‘@-epubx-region’ rule
- Primary flows: the ‘@-epubx-flow’ rule
- Viewport control: the ‘@-epubx-viewport’ rule
What Is It For?
Is It Needed, and Is It a Good Idea?
But your final point is the one I feel the most keenly. Quite a few reading system vendors are hostile to ebook designers, override the stylesheets that come with the ebooks, or otherwise make the designer’s life very difficult. I’ve never seen anything like the mess we have with ePub reading systems, even during the worst days of the browser wars.
But, if reading system vendors don’t accept that they need to follow the CSS spec’s basic rules on the cascade order, where the author declarations take precedence over both user agent and user normal declarations, then, in the immortal words of one of the marines in Aliens, it’s: “Game over, man. Game over!”
There’s no point in using CSS as a part of the base ePub spec if the implementors can’t agree on following one of its basic principles.
This hits a key point that many designers are experiencing with the Nook Color default to a setting that ignores embedded faults and the publisher’s preferences in favor of the reader’s preferences. If it continues, I fear Bjarnason is right about a race to the bottom in terms of styling content as simply as possible to avoid reading platform rendering issues.
If you create ePUBs, I encourage you to read the working document on CSS Page Templates and let the IDPF know what you think. The only way to build a good specification is if the people who will have to work with it every day have a say in how it is created.
What do you think of the CSS Page Template document? Will you use it if it become part of the specification? Do you see other problems with it?