Standard CSS for Epub Files

From MobileRead
Jump to: navigation, search

This page contains some standard CSS which is especially useful for ePub output. In general, this CSS works cross-platform and across devices. Listed are some typical formatting situations you will find in ebook production and the "standard" way to get things done. If there are device-specific hacks, they probably should be listed on the Device pages. Note that Kindle/Mobi format is different from ePub, and what is standard for Kindle may not apply to these CSS examples.

Matt Harrison has put together a Epub CSS Starter Kit which includes a generic base css for epub files.

See also: Table listing CSS properties and support on devices:

Contents

[edit] Images

[edit] Ebook Covers

[edit] Captions

The best way to handle captions is to place them inside a div statement along with the image and then use the following:

.caption {display:inline-block;
          text-align:center;
         }

On some readers using page-break-inside:avoid may also work on the div grouping.

[edit] Hyperlinks

[edit] Widows and Orphans

Set the number of lines needed for widows and orphans separately, setting to 1 effectively turns off Widows and Orphans overriding the default in some readers. May be changed on a paragraph by paragraph basis.

body {widows:1;
      orphans:1;
     }

[edit] Centering and Justification

[edit] Hyphenation

  • Turning off Hyphenation
h1.title, .h2.title, h3.title {
   -webkit-hyphens: none !important;
   adobe-hyphenate: none;
   -moz-hyphens: none;
   hyphens: none;
}

[edit] TOC

[edit] Title/Copyright Page

[edit] For more examples

Personal tools
Namespaces

Variants
Actions
Navigation
MobileRead Networks
Toolbox