The visual appearance of content is often the only consideration that ebook authors take into account when producing content, but this focus excludes that many readers are not going to be reading visually (e.g., refreshable braille, text-to-speech playback, etc.). Separating style from markup is consequently not just about keeping CSS in a separate file from your markup, but recognizing that markup must convey meaning to be useful to all readers, and that visual rendering is only one possible use case.
To create rich markup, EPUB 3 includes the epub:type
attribute
for semantic inflection — the ability to make statements about the nature of the tagging you're
using beyond just the tag name. Using this attribute with the most relevant structural tag is the most
effective way to create meaningful structures that promote accessibility regardless of the medium used to
read the content — by establishing the logical reading order.
Semantically-rich markup also enables meaningful styling, as the epub:type
attribute can be
used in CSS selectors to apply styling by purpose. (See Example 2.) The use of
semantic styling is encouraged as it ensures focus is kept on how the data is represented, not just how
it looks when rendered.
But also note that the choices that you make for your content are not necessarily the optimal ones for many visual readers. A reader may prefer a different color scheme, to increase the contrast levels, to change the justification, fonts or line height to better suit their needs.
For this reason, cleanly separating style information from the markup is a good practice to maintain.
Avoid using the style
attribute, as it can impede the ability of readers to reflow and
re-style documents.
CSS style definitions can be linked to the content documents to which they apply via the HTML5
link
element. Multiple style sheets may be attached to a document to target different
rendering mediums and/or to more cleanly group style by function.
epub:type
attribute