XML technologies / ePUB / Open Publication Structure / Integrating layout with CSS / E-Book body type

(Excerpt from “E-Books mit ePUB ─ Von Word zum E-Book mit XML” by Dr. Victor Wang)

Body type usually starts typographic design: the font used for most ordinary text. Its parameters normally include typeface, face or style, and size.

It is fundamental because it strongly influences subsequent layout, normally determining spacing and heading or other block fonts.

This applies first to print. Does it also apply to e-books? Not all print body-type properties transfer unambiguously.

First consider the CSS property font-family. It can name a specific typeface available on the reader and/or describe the family generically:

For example, a paragraph could use the style attribute style="font-family:'Times New Roman', Times, serif". This chooses in three stages: Times New Roman first, any Times face if unavailable, and finally any serif typeface.

Within a family, different faces vary in weight, width and slope. Three CSS properties provide comparable distinctions: font-weight for weight, font-style for slope, and font-stretch for width. The table lists possible values.

Weight (font-weight)

Value

Meaning

bolder / value 900

extra bold

bold / value 700

bold

normal / value 500

normal weight / medium

lighter / value 300 or less

lighter

Slope (font-style)

Value

Meaning

italic

italic

oblique

oblique

normal

normal

Width (font-stretch)

Value

Meaning

ultra-condensed

ultra-condensed

extra-condensed

extra-condensed

semi-condensed

semi-condensed

condensed

condensed

narrower

narrower than normal

normal

normal width

wider

wider than normal

expanded

expanded

semi-expanded

semi-expanded

extra-expanded

extra-expanded

ultra-expanded

ultra-expanded

Table: CSS font faces

In practice, the browser or reader decides which font is used. For example, CSS 2.1 will omit width (font-stretch) because browser support proved inadequate. Some devices follow CSS; others allow a fixed user-selected font overriding CSS.

Body type also requires size and leading, the spacing between text lines. The CSS property font-size controls size; leading uses line-height, line height. Print usually specifies both together in points: 9/11 means 9-point type and 11-point leading. Printed paper makes these absolute. Digital reading size is unpredictable, so specify type and leading relatively using CSS relative units:

We can now define a sample body type:

body {
  font-family: 'Arial', sans-serif;       ①
  margin-left: 10%;                       ②
  margin-right: 10%;                      ②
}
p {
  font-size: 1.0em;                       ③
  line-height: 1.3em;                     ④
  text-indent: 0.8em;                     ⑤
} 

Code example: Defining body type in CSS

First define CSS rules for the whole e-book on the body element <body>. The property font-family at ① first selects Arial, falling back to sans-serif. The properties margin-left and margin-right at ② add 10% left and right margins, imitating print’s unprinted outer and inner margins.

A paragraph-element rule then specifies size and leading for <p>: at ③, size uses the reader’s default font-size: 1.0em. Leading is set with the property line-height, line height, relatively to 1.3em. Finally, ⑤ sets a first-line indent of 0.8em using the property text-indent.

   

 

 

 

back to top