CSS Text
In this chapter you will learn about the following properties:
The indentation of a text’s initial line can be set using the text-indent property:
p {
text-indent: 50px;
}
The distance between characters in a text can be specified using the letter-spacing attribute.
The example that follows shows you how to change the amount of space between characters:
h1 {
letter-spacing: 5px;
}
h2 {
letter-spacing: -2px;
}
The distance between lines can be specified using the line-height property:
p.small {
line-height: 0.8;
}
p.big {
line-height: 1.8;
}
The distance between words in a text can be specified using the word-spacing attribute.
The example that follows shows you how to change the amount of space between words:
p.one {
word-spacing: 10px;
}
p.two {
word-spacing: -2px;
}
The treatment of white-space inside an element is defined by the white-space property.
Here’s an example of how to stop text from wrapping around an element:
p {
white-space: nowrap;
}
| Property | Description |
|---|---|
| letter-spacing | Specifies the space between characters in a text |
| line-height | Specifies the line height |
| text-indent | Specifies the indentation of the first line in a text-block |
| white-space | Specifies how to handle white-space inside an element |
| word-spacing | Specifies the space between words in a text |
CodingAsk.com is designed for learning and practice. Examples may be made simpler to aid understanding. Tutorials, references, and examples are regularly checked for mistakes, but we cannot guarantee complete accuracy. By using CodingAsk.com, you agree to our terms of use, cookie, and privacy policy.
Copyright 2010-2024 by Refsnes Data. All Rights Reserved.