CSS Text
What is Text?
The Text properties are used to style and format text content.
Color:
Sets the color of the text.
p {
color: #333; /* dark gray */
}
Font Family:
Specifies the font of the text. You can define multiple fonts as fallbacks.
body {
font-family: "Arial", sans-serif;
}
Font Size:
Sets the size of the text.
h1 {
font-size: 24px;
}
Font Weight:
Defines the thickness of the characters in the text.
strong {
font-weight: bold;
}
Text Alignment:
Aligns the text within its container.
p {
text-align: justify;
}
Text Decoration:
Adds decoration to the text, like underline, overline, or line-through.
a {
text-decoration: none; /* removes underline from links */
}
Line Height:
Sets the height of a line of text. It's often used for better readability.
article {
line-height: 1.5;
}
Letter Spacing:
Adjusts the space between characters.
h2 {
letter-spacing: 2px;
}
Word Spacing:
Adjusts the space between words.
p {
word-spacing: 5px;
}
The sample see different ways to customize and style the text content with the use of the text attributes.