In this tutorial, you will learn-
In this article, you will learn-
CSS Text Spacing
CSS text spacing addresses space between words, space among letters, and space between two lines, and space between two paragraphs. It might likewise be called font spacing or character spacing
Text Indentation
The text-indent property is used to specify the indentation of the primary line of a text:
Example
p { text-indent: 50px; }
Letter Spacing
The letter-spacing property is used to specify the space between the characters in a text.
The accompanying example shows how to increment or lessening the space between characters:
Example
<!DOCTYPE html> <html> <head> <style> h1 { letter-spacing: 3px; } h2 { letter-spacing: -3px; } </style> </head> <body> <h1>This is heading 1</h1> <h2>This is heading 2</h2> </body> </html>
Line Height
The line-height property is used to specify the space between lines:
Example
<!DOCTYPE html> <html> <head> <style> p.small { line-height: 0.7; } p.big { line-height: 1.8; } </style> </head> <body> <p> This is a paragraph with a standard line-height.<br> The default line height in most browsers is about 110% to 120%.<br> </p> <p class="small"> This is a paragraph with a smaller line-height.<br> This is a paragraph with a smaller line-height.<br> </p> <p class="big"> This is a paragraph with a bigger line-height.<br> This is a paragraph with a bigger line-height.<br> </p> </body> </html>
Word Spacing
The word-spacing property is used to specify the space between the words in a text.
The accompanying example shows how to increment or lessening the space between words:
Example
<!DOCTYPE html> <html> <head> <style> h1 { word-spacing: 10px; } h2 { word-spacing: -5px; } </style> </head> <body> <h1>This is heading 1</h1> <h2>This is heading 2</h2> </body> </html>
White Space
The white-space property specifies how white-space inside an element is handled.
This example shows how to disable text wrapping inside an element:
<!DOCTYPE html> <html> <head> <style> p { white-space: nowrap; } </style> </head> <body> <h2>White Space</h2> <p> This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. </p> <p>Try to remove the white-space property to see the difference.</p> </body> </html>
Thanks for reading! We hope you found this tutorial helpful and we would love to hear your feedback in the Comments section below. And show us what you’ve learned by sharing your projects with us.