CSS Font Properties: Detailed Notes

CSS font properties allow you to style and control the appearance of text. Below are the frequently used properties with detailed descriptions and examples:


1. font-family

Defines the font typeface for an element.


2. font-size

Sets the size of the text.


3. font-style

Specifies whether the font should be italic, oblique, or normal.


4. font-variant

Used to display text in small-caps or other stylistic variants.


5. font-weight

Defines the thickness of the font characters.


6. line-height

Sets the space between lines of text.


7. letter-spacing

Defines the spacing between characters.


8. word-spacing

Defines the spacing between words.


9. text-transform

Controls the capitalization of text.


10. font (Shorthand Property)

A shorthand for multiple font-related properties.


Practical Exercises

  1. Combine font properties
    • Create a styled heading with bold text, uppercase transformation, and a specific font family.
  2. Experiment with spacing
    • Adjust letter-spacing and word-spacing to see how they affect readability.
  3. Responsive design
    • Use em and rem for font-size and line-height to ensure text adjusts well on different devices.