CSS Text Properties
Word Spacing
| Syntax: | word-spacing: <value> |
|---|---|
| Possible Values: | normal | <length> |
| Initial Value: | normal |
| Applies to: | All elements |
| Inherited: | Yes |
The word-spacing property defines an additional amount of space between words. The value must be in the length format; negative values are permitted.
Examples:
P EM { word-spacing: 0.4em }
P.note { word-spacing: -0.2em }
Letter Spacing
| Syntax: | letter-spacing: <value> |
|---|---|
| Possible Values: | normal | <length> |
| Initial Value: | normal |
| Applies to: | All elements |
| Inherited: | Yes |
The letter-spacing property defines an additional amount of space between characters. The value must be in the length format; negative values are permitted. A setting of 0 will prevent justification.
Examples:
H1 { letter-spacing: 0.1em }
P.note { letter-spacing: -0.1em }
Text Decoration
| Syntax: | text-decoration: <value> |
|---|---|
| Possible Values: | none | [
underline ||
overline ||
line-through ||
blink ] |
| Initial Value: | none |
| Applies to: | All elements |
| Inherited: | No |
The text-decoration property allows text to be decorated through one of five properties: underline, overline, line-through, blink, or the default, none.
For example, one can suggest that links not be underlined with
A:link, A:visited, A:active { text-decoration: none }
Vertical Alignment
| Syntax: | vertical-align: <value> |
|---|---|
| Possible Values: | baseline
| sub |
super |
top |
text-top |
middle |
bottom |
text-bottom |
<percentage> |
| Initial Value: | baseline |
| Applies to: | Inline elements |
| Inherited: | No |
The vertical-align property may be used to alter the vertical positioning of an inline element, relative to its parent element or to the element's line. (An inline element is one which has no line break before and after it, for example, EM, A, and IMG in HTML.)
The value may be a percentage relative to the element's line-height property, which would raise the element's baseline the specified amount above the parent's baseline. Negative values are permitted.
The value may also be a keyword. The following keywords affect the positioning relative to the parent element:
- baseline (align baselines of element and parent)
- middle (align vertical midpoint of element with baseline plus half the x-height--the height of the letter "x"--of the parent)
- sub (subscript)
- super (superscript)
- text-top (align tops of element and parent's font)
- text-bottom (align bottoms of element and parent's font)
The keywords affecting the positioning relative to the element's line are
- top (align top of element with tallest element on the line)
- bottom (align bottom of element with lowest element on the line)
The vertical-align property is particularly useful for aligning images. Some examples follow:
IMG.middle { vertical-align: middle }
IMG { vertical-align: 50% }
.exponent { vertical-align: super }
Text Transformation
| Syntax: | text-transform: <value> |
|---|---|
| Possible Values: | none | capitalize
| uppercase |
lowercase |
| Initial Value: | none |
| Applies to: | All elements |
| Inherited: | Yes |
The text-transform property allows text to be transformed by one of four properties:
- capitalize (capitalizes first character of each word)
- uppercase (capitalizes all characters of each word)
- lowercase (uses small letters for all characters of each word)
- none (the initial value)
Examples:
H1 { text-transform: uppercase }
H2 { text-transform: capitalize }
The text-transform property should only be used to express a stylistic desire. It would be inappropriate, for example, to use text-transform to capitalize a list of countries or names.
Text Alignment
| Syntax: | text-align: <value> |
|---|---|
| Possible Values: | left | right | center | justify |
| Initial Value: | Determined by browser |
| Applies to: | Block-level elements |
| Inherited: | Yes |
The text-align property can be applied to block-lebel elements (P, H1, etc.) to give the alignment of the element's text. This property is similar in function to HTML's ALIGN attribute on paragraphs, headings, and divisions.
Some examples follow:
H1 { text-align: center }
P.newspaper { text-align: justify }
Text Indentation
| Syntax: | text-indent: <value> |
|---|---|
| Possible Values: | <length> |
<percentage> |
| Initial Value: | 0 |
| Applies to: | Block-level elements |
| Inherited: | Yes |
The text-indent property can be applied to block-level elements(P, H1, etc.) to define the amount of indentation that the first line of the element should receive. The value must be a length or a percentage; percentages refer to the parent element's width. A common use of text-indent would be to indent a paragraph:
P { text-indent: 5em }
Line Height
| Syntax: | line-height: <value> |
|---|---|
| Possible Values: | normal | <number> | <length>
| <percentage> |
| Initial Value: | normal |
| Applies to: | All elements |
| Inherited: | Yes |
The line-height property will accept a value to control the spacing between baselines of text. When the value is a number, the line height is calculated by multiplying the element's font size by the number. Percentage values are relative to the element's font size. Negative values are not permitted.
Line height may also be given in the font property along with a font size.
The line-height property could be used to double space text:
P { line-height: 200% }
IE 3.x incorrectly treats number values and values with em or ex units as pixel values. This bug can easily make pages unreadable, and so authors should avoid provoking it wherever possible; percentage units are often a good choice.
- CSS Menus
- CSS Introduction
- CSS Reference
- 1 About the CSS2 Specification
- 2 Introduction to CSS2
- 3 Conformance: Requirements and Recommendations
- 4 CSS2 syntax and basic data types
- 5 Selectors
- 6 Assigning property values, Cascading, and Inheritance
- 7 Media types
- 8 Box model
- 9 Visual formatting model
- 9.1 Introduction to the visual formatting model
- 9.2 Controlling box generation
- 9.3 Positioning schemes
- 9.4 Normal flow
- 9.5 Floats
- 9.6 Absolute positioning
- 9.7 Relationships between 'display', 'position', and 'float'
- 9.8 Comparison of normal flow, floats, and absolute positioning
- 9.9 Layered presentation
- 9.10 Text direction: the 'direction' and 'unicode-bidi' properties
- 10 Visual formatting model details
- 10.1 Definition of "containing block"
- 10.2 Content width: the 'width' property
- 10.3 Computing widths and margins
- 10.4 Minimum and maximum widths: 'min-width' and 'max-width'
- 10.5 Content height: the 'height' property
- 10.6 Computing heights and margins
- 10.7 Minimum and maximum heights: 'min-height' and 'max-height'
- 10.8 Line height calculations: the 'line-height' and 'vertical-align' properties
- 11 Visual effects
- 12 Generated content, automatic numbering, and lists
- 13 Paged media
- 14 Colors and Backgrounds
- 15 Fonts
- 16 Text
- 17 Tables
- 18 User interface
- 19 Aural style sheets
- 19.1 Introduction to aural style sheets
- 19.2 Volume properties: 'volume'
- 19.3 Speaking properties: 'speak'
- 19.4 Pause properties: 'pause-before', 'pause-after', and 'pause'
- 19.5 Cue properties: 'cue-before', 'cue-after', and 'cue'
- 19.6 Mixing properties: 'play-during'
- 19.7 Spatial properties: 'azimuth' and 'elevation'
- 19.8 Voice characteristic properties: 'speech-rate', 'voice-family', 'pitch', 'pitch-range', 'stress', and 'richness'
- 19.9 Speech properties: 'speak-punctuation' and 'speak-numeral'
- Appendix A. A sample style sheet for HTML 4.0
- Appendix B. Changes from CSS1
- Appendix C. Implementation and performance notes for fonts
- Appendix D. The grammar of CSS2
- Appendix E. References
- Appendix F. Property index
- Appendix G. Descriptor index
- Appendix H. Index
