13.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 0.5 inches 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 CSS 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 this. 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.

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 four legal values in CSS2: normal , pre , nowrap , and inherit . CSS 2.1 adds pre-wrap and pre-line . 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. pre-wrap means that the text can be wrapped but runs of whitespace will not be compressed to a single space. Furthermore, all line breaks in the source will still be line breaks in the formatted document. Pre-line means runs of whitespace will be compressed, but line breaks will not be changed to spaces. In other words, all line breaks are preserved and others may be added as necessary. Finally, inherit simply takes on the same behavior as the parent element.



XML in a Nutshell
XML in a Nutshell, Third Edition
ISBN: 0596007647
EAN: 2147483647
Year: 2003
Pages: 232

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net