CSS provides a number of text and font properties that allow you to control the appearance of text on a webpage. These properties allow you to specify the font family, font size, font weight, font style, text alignment, text decoration, and line height of your text.
Font Family: The font family property is used to specify the font used for the text. This property allows you to define a list of font families in order of preference, separated by commas. If the first font in the list is not available on the user's computer, the browser will use the next font in the list.
Font Size: The font size property is used to specify the size of the text. You can use different units such as pixels, ems, or percentages to define the size. The default font size for most browsers is 16px.
Font Weight: The font weight property is used to specify the weight of the text, such as normal, bold, or bolder.
Font Style: The font style property is used to specify the style of the text, such as normal, italic, or oblique.
Text Alignment: The text alignment property is used to specify the horizontal alignment of the text within its container, such as left, right, center, or justify.
Text Decoration: The text decoration property is used to specify the decoration of the text, such as underline, overline, or line-through.
Line Height: The line height property is used to specify the height of each line of text. You can use different units to define the height.
Font Family: The font family property is used to specify the font used for the text. This property allows you to define a list of font families in order of preference, separated by commas. If the first font in the list is not available on the user's computer, the browser will use the next font in the list.
Font Size: The font size property is used to specify the size of the text. You can use different units such as pixels, ems, or percentages to define the size. The default font size for most browsers is 16px.
Font Weight: The font weight property is used to specify the weight of the text, such as normal, bold, or bolder.
Font Style: The font style property is used to specify the style of the text, such as normal, italic, or oblique.
Text Alignment: The text alignment property is used to specify the horizontal alignment of the text within its container, such as left, right, center, or justify.
Text Decoration: The text decoration property is used to specify the decoration of the text, such as underline, overline, or line-through.
Line Height: The line height property is used to specify the height of each line of text. You can use different units to define the height.
Example
<!DOCTYPE html>
<html>
<head>
<title>CSS Text and Font Properties</title>
<style>
p {
font-family: Arial, sans-serif;
font-size: 18px;
font-weight: bold;
font-style: italic;
text-align: center;
text-decoration: underline;
line-height: 1.5;
color: #234671;
background-color: #f2f2f2;
padding: 20px;
border: 8px solid #cccccc;
border-radius: 10px;
box-shadow: 5px 9px 9px #888888;
}
</style>
</head>
<body>
<p>This is a sample paragraph that demonstrates the use of CSS text and font properties.</p>
</body>
</html>
Tags:
CSS