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:
serif: a serif typeface
sans-serif: a sans-serif typeface
monospace: monospaced type, every character equally wide
cursive: a cursive typeface
fantasy: an unusual typeface, unpredictable in practice
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 ( | |
|---|---|
Value | Meaning |
| extra bold |
| bold |
| normal weight / medium |
| lighter |
Slope ( | |
Value | Meaning |
| italic |
| oblique |
| normal |
Width ( | |
Value | Meaning |
| ultra-condensed |
| extra-condensed |
| semi-condensed |
| condensed |
| narrower than normal |
| normal width |
| wider than normal |
| expanded |
| semi-expanded |
| extra-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:
%: percentage relative to the current element; examplefont-size: 10pt; line-height: 120%;
ex: based on lowercase x height; example:font-size: 1.3ex; line-height: 1.6ex;
em: based on current element font size; example:font-size: 1.0em; line-height: 1.3em;
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.
Copyright © mitp 2011
You may print the online version for your private use.
Otherwise, this chapter from “E-Books mit ePUB” is subject to the same terms as the printed edition: the work and all its parts are protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
Verlagsgruppe Hüthig Jehle Rehm GmbH, Im Weiher 10, 69121 Heidelberg, kundenbetreuung(at)hjr-verlag.de
back to top