XML technologies / ePUB / ePub für (In)Designer / Images, boxes and other design elements / Defining a background color

(Excerpt from “ePub für (In)Designer — Mit InDesign Schritt für Schritt zum E-Book” by Sascha Heck & Yves Apel)

Background colors are uncommon in e-books. Print uses them mainly for special pages; ePub often overlooks them, although they are easy to add afterward. Two methods let you color either one chapter or the whole book.

Setting one chapter’s background

Open its HTML file in an editor. Find <body> and change it to <body style="background-color: #f8ff95">, where #f8ff95 stands for any color code. To find a specific hexadecimal color, see Defining hexadecimal colors.

Specifying a background in HTML

Figure: Specifying a background in HTML.

Changing the whole book’s background

Open the ePub’s template.css file in an editor and add these lines:

body {
  background-color: #f8ff95;
}

The background now has its new color.

Yellow background in Adobe Digital Editions

Figure: Yellow background in Adobe Digital Editions.

Again, not every reader supports background colors.

iBooks has normal and sepia modes and, since 1.5, a night mode intended to ease reading in darkness. Night mode overrides background-color settings.

Normal, sepia and night modes in iBooks
Figure: Normal, sepia and night modes in iBooks.

  

 

 

 

back to top