CSS Text
When working with CSS, there are several properties you can use to style text on your webpage. These properties allow you to change the font, size, color, alignment, and more. In this tutorial, we will cover some of the most commonly used CSS text properties.
Font Family
The font-family property allows you to specify the font that should be used for text on your webpage. You can choose from a list of font families, or specify a specific font to use. Here is an example:
p {
font-family: Arial, sans-serif;
}
Font Size
The font-size property allows you to specify the size of the text. You can use different units of measurement, such as pixels or ems. Here is an example:
p {
font-size: 16px;
}
Font Color
The color property allows you to specify the color of the text. You can use color names, hex codes, RGB values, or HSL values. Here is an example:
p {
color: #333333;
}
Text Alignment
The text-align property allows you to specify how the text should be aligned within its container. You can choose from left, right, center, or justify. Here is an example:
p {
text-align: center;
}
Text Decoration
The text-decoration property allows you to add decorations to text, such as underline, overline, line-through, or none. Here is an example:
p {
text-decoration: underline;
}
Font Weight
The font-weight property allows you to specify the weight of the text, such as bold or normal. Here is an example:
p {
font-weight: bold;
}
Line Height
The line-height property allows you to specify the height of each line of text. You can use different units of measurement, such as pixels or ems. Here is an example:
p {
line-height: 1.5;
}
Letter Spacing
The letter-spacing property allows you to specify the spacing between letters. You can use different units of measurement, such as pixels or ems. Here is an example:
p {
letter-spacing: 2px;
}