← toolkit.bot

EPUB CSS — A Complete Styling Guide for E-Reader Publishing

CSS in EPUBs works like web CSS, but e-readers impose restrictions and quirks. Here's what you can use, what to avoid, and patterns that work across Kindle, Kobo, and Apple Books.

How EPUB CSS Works

EPUB chapter files are XHTML documents that reference CSS stylesheets in the Styles/ folder. CSS is linked in the <head> of each chapter:

<link rel="stylesheet" type="text/css" href="../Styles/styles.css"/>

EPUB 3 uses the CSS 2.1 + CSS 3 subset defined in the EPUB 3 CSS Profile. Readers implement this profile at varying levels — Kindle, Kobo, and Apple Books each have quirks and gaps.

Safe CSS — Works Everywhere

/* Body and text */
body {
  font-family: serif; /* let readers override with their font */
  font-size: 1em;     /* relative to reader's user font size */
  line-height: 1.5;
  margin: 0;
  padding: 0;
}

/* Headings */
h1 { font-size: 1.8em; margin: 1.5em 0 0.5em; text-align: center; }
h2 { font-size: 1.4em; margin: 1.2em 0 0.4em; }
h3 { font-size: 1.1em; margin: 1em 0 0.3em; }

/* Paragraphs */
p { margin: 0; text-indent: 1.2em; }
p.first-para, h1 + p, h2 + p { text-indent: 0; } /* no indent after heading */

/* Links */
a { color: inherit; text-decoration: underline; }

/* Images */
img { max-width: 100%; height: auto; display: block; }

/* Code */
pre, code { font-family: monospace; font-size: 0.9em; }
pre { white-space: pre-wrap; overflow-wrap: break-word; }

CSS to Avoid in EPUBs

Property Problem Alternative
position: fixedRejected by EPUBCheck; broken on all readersDon't use
vh, vw unitsViewport units ignored or broken on most readersUse em, %, or pixel units
float: left/rightInconsistent across readers; breaks reflowingUse margins/padding for spacing
display: gridNot supported on older Kindle firmwareUse tables or simple flexbox
@media queriesPartial support; don't rely on breakpointsDesign for single-column reflow
font-size: pxOverrides user font size settingUse em or rem

Page Breaks

Control page breaks between chapters using CSS:

/* Force chapter to start on new page (paginated readers) */
h1.chapter-title { page-break-before: always; }

/* EPUB 3 equivalent (use both for compatibility) */
h1.chapter-title {
  page-break-before: always;
  break-before: page;
}

In scroll mode readers (Thorium Reader scroll mode, iBooks on iPhone in some orientations), page breaks are ignored — they only affect paginated reading modes.

Drop Caps

p.drop-cap::first-letter {
  font-size: 3em;
  float: left;
  line-height: 0.8;
  margin: 0.1em 0.1em 0 0;
  font-weight: bold;
}

Drop caps work in Apple Books and Thorium Reader. Kindle renders ::first-letter but the float behavior is inconsistent. Test before using in production.

Tables

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
  margin: 1em 0;
}
th, td {
  border: 1px solid #ccc;
  padding: 0.4em 0.6em;
  text-align: left;
}
th { font-weight: bold; background-color: #f0f0f0; }

Background colors on table cells render in Apple Books and Kobo. Kindle ignores background colors by default when in sepia/night mode — don't rely on them for essential information.

Reader-Specific Notes

Converting a PDF to EPUB? toolkit.bot generates clean semantic HTML ready for CSS styling.

Convert PDF to EPUB →

Related guides