loading

Text Spacing


Text Spacing

In this chapter you will learn about the following properties:

  • text-indent
  • letter-spacing
  • line-height
  • word-spacing
  • white-space

Text Indentation

The indentation of a text’s initial line can be set using the text-indent property:

Example

				
					p {
  text-indent: 50px;
}

				
			

Letter Spacing

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:

Example

				
					h1 {
  letter-spacing: 5px;
}

h2 {
  letter-spacing: -2px;
}
				
			

Line Height

The distance between lines can be specified using the line-height property:

Example

				
					p.small {
  line-height: 0.8;
}

p.big {
  line-height: 1.8;
}
				
			

Word Spacing

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:

Example

				
					p.one {
  word-spacing: 10px;
}

p.two {
  word-spacing: -2px;
}
				
			

White Space

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:

Example

				
					p {
  white-space: nowrap;
}
				
			

The CSS Text Spacing Properties

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
Share this Doc

Text Spacing

Or copy link

Explore Topic