HTML and CSS [Electronic resources]

Molly E. Holzschlag

نسخه متنی -صفحه : 198/ 115
نمايش فراداده

Indenting Text

Another very useful text property is text-indent. This enables you to indent text with CSS instead of spacer graphics or numerous nonbreaking space characters in you189.

You can use any length value (described earlier this chapter) that is fixed.

p {text-indent: 45px;}

This results in each paragraph having an initial indentation of 45 pixels (see Figure 9-10).

Figure 9-10. Indenting paragraphs with a 45-pixel indent.

Chapter 12, "Positioning, Floats, and Z-Index"):

p {text-indent: 40%;}

This results in a deep indentation, which you can use from time to time for an unusual look (see Figure 9-11).

Figure 9-11. Indenting using percentages.

[View full size image]

You can use negative length values to

outdent text (see Figure 9-12).

Figure 9-12. Outdenting text by setting margins and applying text-indent: -20px;.