Line Spacing in CSS
Now let's learn how to set the line spacing for the text. Line spacing means the distance between the lines of text, that is, the white space between them. The line-height
property is intended for this, setting the height of the text line.
There's a catch when using the line-height
property: this property doesn't set the space between lines of text, as you might think, but sets the height of the text line.
This means that the actual visible space between lines will be calculated as: line-height
- font-size
= the visible space between lines of text.
In the following example, the space between lines of text will be
:
50px
- 20px
= 30px
<p>
long text...
</p>
p {
font-size: 20px;
line-height: 50px;
text-align: justify;
width: 400px;
}
:
Let the font size for paragraphs be 30px
. Set the line-height
property so that the visible white space between paragraphs is 15px
.