The CSS font property is used to control the appearance of text. With this property, you can modify various aspects of text, including its size, color, style, and more. You’ve already learned how to make text bold or underlined. Here, you’ll also discover how to resize your font using percentages.
• Font color: This property changes the color of the text. (This is a standalone attribute.)
• Font family: This property changes the typeface of the font.
• Font size: This property adjusts the size of the font, which can be specified in various units including percentages.
• Font size: This property adjusts the size of the font, which can be specified in various units including percentages.
• Font style: This property allows you to make the font bold, italic, or oblique.
• Font variant: This property enables a small-caps effect for the text.
• Font weight: This property controls the thickness or lightness of the font, affecting its boldness.
Description: Defines the style of the font.
• normal: Default font style.
• italic: Italic text
• oblique: Oblique text (similar to italic but less slanted).
Example: small-caps
Description: Specifies the variant of the font.
• normal: Default font variant.
• small-caps: Transforms text to small capital letters.
Example: small-caps
Description: Sets the thickness of the font.
• normal: Default font weight.
• bold: Bold text.
• bolder: Bolder than the parent element.
• lighter: Lighter than the parent element.
• Numeric values: 100, 200, 300, 400, 500, 600, 700, 800, 900 (where 400 is normal and 700 is bold).
Example: bold, 700
Description: Defines the size of the font.
• Absolute units: px, pt, cm, mm, in
• Relative units: em, rem, %
• initial: Default value of the property.
Example: 16px, 1.5em, 120%
Description: Sets the space between lines of text.
• normal: Default line height.
• number: A unitless number that multiplies the font size.
• length: Absolute length (e.g., px, em).
• percentage: Percentage of the font size.
Example: 1.5, 20px, 150%
Description: Defines the typeface for the text.
• Font names: 'Arial', 'Times New Roman'
• Generic family names: serif, sans-serif, monospace, cursive, fantasy
Example: 'Arial', sans-serif
<!DOCTYPE html>
<html>
<head>
<title>CSS Font Properties Inline</title>
</head>
<body>
<p style="
color: #3498db; /* Font color */
font-family: 'Arial', sans-serif; /* Font family */
font-size: 20px; /* Font size */
font-style: italic; /* Font style */
font-variant: small-caps; /* Font variant */
font-weight: bold; /* Font weight */
">
This is an example of various CSS font properties applied using inline CSS.
</p>
</body>
</html>
This is an example of various CSS font properties applied using inline CSS.