CSS provides a variety of properties that can be used to style text on a web page. Here are some of the most commonly used properties:
color
: This sets the color of the text.
p {
color: red;
}
font-family
: This sets the font family used for the text. It can be a specific font or a generic font family, such asserif
orsans-serif
.
p {
font-family: Arial, sans-serif;
}
font-size
: This sets the size of the text.
p {
font-size: 16px;
}
font-weight
: This sets the weight of the text, such asnormal
,bold
, or a specific numeric value.
p {
font-weight: bold;
}
text-align
: This sets the alignment of the text within its container.
p {
text-align: center;
}
text-decoration
: This sets the decoration for the text, such asunderline
orline-through
.
a {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
text-transform
: This sets the capitalization of the text, such asuppercase
,lowercase
, orcapitalize
.
h1 {
text-transform: uppercase;
}
line-height
: This sets the height of the lines of text.
p {
line-height: 1.5;
}
These are just a few examples of the many properties that can be used to style text in CSS. By combining these properties, you can create a wide variety of text styles and effects for your web page.