CSS Font Properties
CSS provides various font-related properties to control the appearance of text, including font family, size, weight, style, and more.
1. Setting the Font Family (font-family
)
Defines the font type for text. Always include a fallback font.
✅ Uses Arial
; if unavailable, it falls back to any sans-serif
font.
🔹 Common Font Families:
- Serif:
"Times New Roman"
,Georgia
- Sans-serif:
"Arial"
,"Helvetica"
,"Verdana"
- Monospace:
"Courier New"
,"Monaco"
- Cursive:
"Brush Script MT"
2. Setting Font Size (font-size
)
✅ Sets the font size to 24 pixels.
🔹 Units You Can Use:
px
(pixels) – Fixed sizeem
– Relative to parentrem
– Relative to root (html
)%
– Relative to default size
Example:
3. Font Weight (font-weight
)
Controls text boldness.
🔹 Other values:
normal
(default)bold
lighter
/bolder
100
to900
(where100
is thin and900
is extra bold)
Example:
4. Font Style (font-style
)
Controls whether a text is italicized.
🔹 Values: normal
, italic
, oblique
.
5. Font Variant (font-variant
)
Controls small caps text.
✅ Displays lowercase letters as smaller uppercase letters.
6. Font Stretch (font-stretch
)
Adjusts the width of characters.
🔹 Other values: condensed
, semi-condensed
, ultra-expanded
, etc.
7. Shorthand for Fonts (font
)
Instead of writing multiple properties, use a shorthand:
✅ This is equivalent to:
Example Usage in a Full CSS Rule