What is the CSS property used to control the spacing between lines of text within an element?
What is the CSS property used to control the spacing between lines of text within an element?
30406-Jun-2023
Updated on 07-Jun-2023
Home / DeveloperSection / Forums / What is the CSS property used to control the spacing between lines of text within an element?
What is the CSS property used to control the spacing between lines of text within an element?
Aryan Kumar
07-Jun-2023The CSS property used to control the spacing between lines of text within an element is the line-height property. It specifies the height of a line box, which is the area that contains a line of text. The line-height property can be used to increase or decrease the spacing between lines of text.
The line-height property can be set to a number, a percentage, or a keyword. A number specifies the height of the line box in terms of the font size. For example, a line-height value of 1.5 will set the height of the line box to 1.5 times the font size. A percentage specifies the height of the line box as a percentage of the height of the containing element. For example, a line-height value of 120% will set the height of the line box to 120% of the height of the containing element. A keyword can be used to set the line height to a specific value. The available keywords are:
The line-height property can be used to control the spacing between lines of text in any element. However, it is most commonly used to control the spacing between lines of text in paragraphs.
Here is an example of how to use the line-height property to increase the spacing between lines of text in a paragraph:
Code snippet
This code will set the line height of all paragraphs to 1.5 times the font size. This will increase the spacing between lines of text, making the paragraph easier to read.