View Full Version : In an ePub reader, what are the rules for processing styles/CSS?


mattcurtis
04-05-2013, 10:42 AM
Hey guys (new user here),

I'm developing an ePub reader, and although I've searched and searched, I can't find the rules for ePub style processing/display. Here are my main questions:


Should the reader display the styles/css referenced in the HTML of the current text file, or from the OPF?
Is it mandatory to display CSS from the ePub?
Where can I find more info on this?


Thanks in advance.

Jellby
04-05-2013, 11:11 AM
Should the reader display the styles/css referenced in the HTML of the current text file, or from the OPF?

HTML. The OPF is just a reference of the files contained in the package (and some metadata, and in which order the HTML files should be displayed), but the rendering should be (mostly) according to XHTML+CSS.

Is it mandatory to display CSS from the ePub?

According to the spec:

In a number of cases, this specification does not require Reading Systems to provide the full range of rendering that a standard CSS style sheet might request. For example, some Reading Systems will use monochrome displays. It would neither be acceptable to limit all Reading Systems to monochrome, nor to declare color use a non-standardized extension beyond OPS. In such cases, the CSS settings are allowed, and keep their meanings; but a conforming Reading System may gracefully degrade to a simpler rendering.

A conforming Reading System must render all OPS CSS 2.0 required subset properties. A Reading System may support CSS properties beyond the OPS CSS 2.0 required subset, however, any unsupported properties must be gracefully degraded per the CSS 2.0 specification.

Where can I find more info on this?

http://idpf.org/epub

and in particular, EPUB 2.0.1, OPS (http://www.idpf.org/epub/20/spec/OPS_2.0.1_latest.htm). Unless you want to write an EPUB 3 reader, then it's more complicated, but the info is there as well.