CSS Font
The CSS font
property is used to set the font style, size, weight, family, and other font-related properties of text. Here’s an example of using the font
property to style text:
body {
font-family: Arial, sans-serif;
font-size: 16px;
font-weight: normal;
font-style: normal;
line-height: 1.5;
color: #333;
}
In this example, we’ve set the font family to Arial and specified a fallback of sans-serif in case Arial is not available. We’ve also set the font size to 16 pixels, font weight to normal, font style to normal, line height to 1.5, and text color to #333.
The font
property can also be used to set individual font-related properties, such as font-size
, font-style
, font-weight
, font-family
, and line-height
, separately.
Additionally, CSS provides a variety of font-related properties, such as text-align
, text-decoration
, text-transform
, and letter-spacing
, that can be used to further style text on a web page.
When choosing fonts for a web page, it’s important to consider factors such as readability, accessibility, and cross-browser compatibility. It’s also a good practice to use web-safe fonts or include custom fonts using the @font-face
rule to ensure that the fonts are available and displayed consistently across different browsers and devices.