XML technologies / CSS / CSS Cookbook / Typography for the web / Indenting the first line of a paragraph
(Excerpt from “CSS Kochbuch” by Christopher Schmitt)
Problem
You want to indent the first line of each paragraph, turning the paragraphs in the next figure into those in the figure after it.
Figure: Default paragraph display.
Figure: The first line of each paragraph has been indented.
Solution
Use the property text-indent to create the indentation:
p {
text-indent: 2.5em;
margin: 0 0 0.5em 0;
padding: 0;
}Discussion
The property text-indent accepts absolute and relative length units as well as percentages. Percentages refer to the parent element’s width, rather than the entire page width. Thus, for a 200-pixel-wide paragraph, a 35% indentation means an offset of 70 pixels.
See also
The CSS 2.1 specification for more information on the property text-indent.
Copyright of the German edition © 2007 by O’Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from “CSS Kochbuch” is subject to the same conditions as the bound edition: the work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstr. 81, 50670 Köln