The CSS Text property defines the appearance of Text, such as the color of Text, the alignment of Text, the decoration of Text, the indentation of Text, the line spacing, and so on

Text color

The color property defines the color of the text

div {
	color:red;
}
Copy the code
  • Predefined color values: red, green, etc
  • Hexadecimal: #FF0000
  • RGB code: RGB (255,0,0) or RGB (100%,0%,0%)

Aligned text

The text-align attribute sets the horizontal alignment of text content within an element

div {
	text-align:center;
}
Copy the code
  • Essentially, the text inside the box is horizontally centered
Attribute values explain
left The left
right Align right
center Align center

Text decoration

The text-decoration property specifies the decorations to be added to the text. You can add underscores, strippers, and hyphens to the text.

div {
            text-decoration: underline;
}
Copy the code
Attribute values describe
none The default. No decorative thread (most commonly used)
underline The underline. Link A comes with an underscore (common)
overline Underline (rarely used)
line-through Delete line (rarely used)

Text indentation

The text-indent property is used to specify the indentation of the first line of text, usually the first line of a paragraph

p {
   text-indent: 10px;
}
Copy the code

By setting this property, the first line of all elements can be indented by a given length, even if the length can be negative.

p {
	text-indent:2em;
}
Copy the code
  • Em is a relative unit of the size of the current element, or the size of the parent element if the current element is not set.
  • In the case of Chinese characters, 2em represents the distance between the current element and two text sizes

Line spacing

The line-height property sets the distance between lines. It controls the distance between lines of text.

p {
	line-height:26px;
}
Copy the code

Volume line height tool: FSCapture