home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Book HomeXML in a NutshellSearch this book

12.8. Text Properties

Text properties cover those aspects of text formatting other than what can be adjusted merely by changing the font. These include how far the text is indented, how the paragraph is aligned, and so forth. The most common of these properties include:

text-indent
The text-indent property specifies how far in to indent the first line of the block. (Indents of all lines are generally applied via margin properties.) Hanging indents can be specified by making text-indent negative. This property only applies to block-level elements. For example, this style rule indents the first line of the story element by half an inch from the left side:

story { text-indent: 0.5in }
text-align
The text-align property can be set to left, right, center, or justify to align the text with the left edge of the block or the right edge of the block, to center the text in the block, or to spread the text out across the block. This property only applies to block-level elements.

text-decoration
The text-decoration property can be set to underline, overline, line-through or blink to produce the obvious effects. Note, however, that the CSS2 specification specifically allows browsers to ignore the request to make elements blink. This is a good thing.

text-transform
The text-transform property has three main values: capitalize, uppercase, and lowercase. Uppercase changes all the text to capital letters LIKE THIS. Lowercase changes all the text to lowercase letters like these. Capitalize simply uppercases the first letter of each word Like This, but leaves the other letters alone. The default value of this property is none, which performs no transformation. It can also be set to inherit to indicate that the same transform as used on the parent element should be used.

TIP: Changing the case in English is fairly straightforward, but this isn't true of all languages. In particular, software written by native English speakers tends to do a very poor job of algorithmically changing the case in ligature-heavy European languages like Maltese or context-sensitive languages like Arabic. Outside of English text, it's best to make the transformations directly in the source document rather than relying on the stylesheet engine to make the correct decisions about which letters to capitalize.

white-space
The white-space property determines whether text is wrapped. It has only four legal values: normal, pre, nowrap, and inherit. Normal is of course the default and simply means to wrap the text wherever convenient, much as is done in this paragraph. Pre means to preserve all line breaks and whitespace in the document, as does the pre element in HTML. Nowrap means that runs of whitespace can be condensed, but that line breaks will not be inserted. Finally, inherit simply takes on the same behavior as the parent element.



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.